diff --git a/.gitignore b/.gitignore index f84c225c2ba..ef696edb785 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,3 @@ yarn.lock # source maps of docs docs/**/*.map - -# open collective badge -.lastocprint diff --git a/bin/cli.js b/bin/cli.js index bd2f3602565..108aa3c6b55 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -7,7 +7,6 @@ (function() { // wrap in IIFE to be able to use return - const importLocal = require("import-local"); // Prefer the local installation of webpack-cli if (importLocal(__filename)) { @@ -473,7 +472,19 @@ For more information, see https://webpack.js.org/api/cli/.`); const statsString = stats.toString(outputOptions); const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : ""; if (statsString) stdout.write(`${statsString}\n${delimiter}`); - require("./opencollective"); + + + const now = new Date(); + const MONDAY = 2; + const SIX_DAYS = 518400000; + if (now.getDay() === MONDAY) { + const statSync = require("fs").statSync; + const lastPrint = statSync(__dirname + "/opencollective.js").atime; + const lastPrintTS = new Date(lastPrint).getTime(); + if (now.getTime() - lastPrintTS > SIX_DAYS) { + require("./opencollective"); + } + } } if (!options.watch && stats.hasErrors()) { process.exitCode = 2; diff --git a/bin/opencollective.js b/bin/opencollective.js index c542a868a84..a6266a25b4e 100644 --- a/bin/opencollective.js +++ b/bin/opencollective.js @@ -1,6 +1,4 @@ const chalk = require("chalk"); -const fs = require("fs"); -const path = require("path"); // Only show emoji on OSx (Windows shell doesn't like them that much ¯\_(ツ)_/¯ ) function emoji(emoji) { @@ -32,16 +30,4 @@ function printBadge() { console.log("\n"); } - -const now = new Date(); -const MONDAY = 1; -if (now.getDay() === MONDAY) { - const lastPrintFile = path.resolve(__dirname, "../.lastocprint"); - fs.readFile(lastPrintFile, "utf8", (err, lastPrint = 0) => { - if (err && err.code !== "ENOENT") return; - if (now - lastPrint > 6 * 24 * 60 * 60 * 1000) { - printBadge(); - fs.writeFileSync(lastPrintFile, now); - } - }); -} +printBadge();