1 /* eslint-disable max-len -- for better formatting */
2 var fs = require('fs');
3 var os = require('os');
4 var path = require('path');
7 var ADBLOCK = is(env.ADBLOCK);
8 var COLOR = is(env.npm_config_color);
9 var DISABLE_OPENCOLLECTIVE = is(env.DISABLE_OPENCOLLECTIVE);
10 var SILENT = ['silent', 'error', 'warn'].indexOf(env.npm_config_loglevel) !== -1;
11 var OPEN_SOURCE_CONTRIBUTOR = is(env.OPEN_SOURCE_CONTRIBUTOR);
12 var MINUTE = 60 * 1000;
14 // you could add a PR with an env variable for your CI detection
18 'CONTINUOUS_INTEGRATION',
21 ].some(function (it) { return is(env[it]); });
23 var BANNER = '\u001B[96mThank you for using core-js (\u001B[94m https://github.com/zloirock/core-js \u001B[96m) for polyfilling JavaScript standard library!\u001B[0m\n\n' +
24 '\u001B[96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: \u001B[0m\n' +
25 '\u001B[96m>\u001B[94m https://opencollective.com/core-js \u001B[0m\n' +
26 '\u001B[96m>\u001B[94m https://www.patreon.com/zloirock \u001B[0m\n\n' +
27 '\u001B[96mAlso, the author of core-js (\u001B[94m https://github.com/zloirock \u001B[96m) is looking for a good job -)\u001B[0m\n';
30 return !!it && it !== '0' && it !== 'false';
33 function isBannerRequired() {
34 if (ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR) return false;
35 var file = path.join(os.tmpdir(), 'core-js-banners');
38 var DELTA = Date.now() - fs.statSync(file).mtime;
39 if (DELTA >= 0 && DELTA < MINUTE * 3) {
40 banners = JSON.parse(fs.readFileSync(file, 'utf8'));
41 if (banners.indexOf(BANNER) !== -1) return false;
48 fs.writeFileSync(file, JSON.stringify(banners), 'utf8');
49 } catch (error) { /* empty */ }
53 function showBanner() {
54 // eslint-disable-next-line no-console,no-control-regex -- output
55 console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, ''));
58 if (isBannerRequired()) showBanner();