Skip to content

Commit

Permalink
docs(opencollective prompt): improve code clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
misterdev committed Mar 15, 2019
1 parent 3af73a8 commit 55992a4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,18 +474,22 @@ For more information, see https://webpack.js.org/api/cli/.`);
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : "";
if (statsString) stdout.write(`${statsString}\n${delimiter}`);


const now = new Date();
/**
* Show a hint to donate to our Opencollective
* once a week, only on Monday
*/
const openCollectivePath = __dirname + "/opencollective.js";
const MONDAY = 1;
const SIX_DAYS = 518400000;
const openCollectivePath = __dirname + "/opencollective.js";
const now = new Date();
if (now.getDay() === MONDAY) {
const { statSync, utimesSync } = require("fs");
const lastPrint = statSync(openCollectivePath).atime;
const lastPrintTS = new Date(lastPrint).getTime();
if (now.getTime() - lastPrintTS > SIX_DAYS) {
const timeSinceLastPrint = now.getTime() - lastPrintTS;
if (timeSinceLastPrint > SIX_DAYS) {
require(openCollectivePath);
// On windows we need to update the atime
// On windows we need to manually update the atime
utimesSync(openCollectivePath, now, now);
}
}
Expand Down

0 comments on commit 55992a4

Please sign in to comment.