Skip to content

Commit

Permalink
limit postinstall ad to show only one time
Browse files Browse the repository at this point in the history
When installing multiple packages that depend on core-js, the postinstall message will pop up mutiple times which will add unnecessary verbosity to the terminal log. I know zloirock#767, zloirock#548, zloirock#797, zloirock#757, zloirock#781 ,zloirock#729, zloirock#708, refer to this problem and since @zloirock refuses to remove this, lets limit it to one time so that verbosity gets truncated to the least.
  • Loading branch information
retronav authored Apr 12, 2020
1 parent f25e755 commit f8d8280
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core-js/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var os = require('os');
var path = require('path');
var env = process.env;

var AD_SHOWN = is(env.AD_SHOWN)
var ADBLOCK = is(env.ADBLOCK);
var COLOR = is(env.npm_config_color);
var DISABLE_OPENCOLLECTIVE = is(env.DISABLE_OPENCOLLECTIVE);
Expand Down Expand Up @@ -31,7 +32,7 @@ function is(it) {
}

function isBannerRequired() {
if (ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR) return false;
if (ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR || AD_SHOWN) return false;
var file = path.join(os.tmpdir(), 'core-js-banners');
var banners = [];
try {
Expand All @@ -53,6 +54,8 @@ function isBannerRequired() {
function showBanner() {
// eslint-disable-next-line no-console,no-control-regex
console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, ''));
process.env.AD_SHOWN = true

}

if (isBannerRequired()) showBanner();

0 comments on commit f8d8280

Please sign in to comment.