source: trip-planner-front/node_modules/core-js/postinstall.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/* eslint-disable max-len -- for better formatting */
2var fs = require('fs');
3var os = require('os');
4var path = require('path');
5var env = process.env;
6
7var ADBLOCK = is(env.ADBLOCK);
8var COLOR = is(env.npm_config_color);
9var DISABLE_OPENCOLLECTIVE = is(env.DISABLE_OPENCOLLECTIVE);
10var SILENT = ['silent', 'error', 'warn'].indexOf(env.npm_config_loglevel) !== -1;
11var OPEN_SOURCE_CONTRIBUTOR = is(env.OPEN_SOURCE_CONTRIBUTOR);
12var MINUTE = 60 * 1000;
13
14// you could add a PR with an env variable for your CI detection
15var CI = [
16 'BUILD_NUMBER',
17 'CI',
18 'CONTINUOUS_INTEGRATION',
19 'DRONE',
20 'RUN_ID'
21].some(function (it) { return is(env[it]); });
22
23var 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:\u001B[0m\n' +
25 '\u001B[96m>\u001B[94m https://opencollective.com/core-js \u001B[0m\n' +
26 '\u001B[96m>\u001B[94m https://patreon.com/zloirock \u001B[0m\n' +
27 '\u001B[96m>\u001B[94m https://paypal.me/zloirock \u001B[0m\n' +
28 '\u001B[96m>\u001B[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz \u001B[0m\n\n' +
29 '\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
31function is(it) {
32 return !!it && it !== '0' && it !== 'false';
33}
34
35function isBannerRequired() {
36 if (ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR) return false;
37 var file = path.join(os.tmpdir(), 'core-js-banners');
38 var banners = [];
39 try {
40 var DELTA = Date.now() - fs.statSync(file).mtime;
41 if (DELTA >= 0 && DELTA < MINUTE * 3) {
42 banners = JSON.parse(fs.readFileSync(file, 'utf8'));
43 if (banners.indexOf(BANNER) !== -1) return false;
44 }
45 } catch (error) {
46 banners = [];
47 }
48 try {
49 banners.push(BANNER);
50 fs.writeFileSync(file, JSON.stringify(banners), 'utf8');
51 } catch (error) { /* empty */ }
52 return true;
53}
54
55function showBanner() {
56 // eslint-disable-next-line no-console,no-control-regex -- output
57 console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, ''));
58}
59
60if (isBannerRequired()) showBanner();
Note: See TracBrowser for help on using the repository browser.