UNPKG

1.25 kBJavaScriptView Raw
1/* eslint-disable max-len -- for better formatting */
2var env = process.env;
3
4var ADBLOCK = is(env.ADBLOCK);
5var COLOR = is(env.npm_config_color);
6var DISABLE_OPENCOLLECTIVE = is(env.DISABLE_OPENCOLLECTIVE);
7var SILENT = ['silent', 'error', 'warn'].indexOf(env.npm_config_loglevel) !== -1;
8var OPEN_SOURCE_CONTRIBUTOR = is(env.OPEN_SOURCE_CONTRIBUTOR);
9
10// you could add a PR with an env variable for your CI detection
11var CI = [
12 'BUILD_NUMBER',
13 'CI',
14 'CONTINUOUS_INTEGRATION',
15 'DRONE',
16 'RUN_ID'
17].some(function (it) { return is(env[it]); });
18
19var BANNER = '\u001b[35m\u001b[1mLove Swiper? Support Vladimir\'s work by donating or pledging: \u001B[0m\n' +
20'\u001b[22m\u001b[39m\u001b[32m> On Patreon https://patreon.com/vladimirkharlampidi \u001B[0m\n' +
21'\u001b[22m\u001b[39m\u001b[32m> On Open Collective https://opencollective.com/swiper';
22
23function is(it) {
24 return !!it && it !== '0' && it !== 'false';
25}
26
27function isBannerRequired() {
28 return !(ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR);
29}
30
31function showBanner() {
32 // eslint-disable-next-line no-console,no-control-regex -- output
33 console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, ''));
34}
35
36if (isBannerRequired()) showBanner();