Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(opencollective-prompt): check write permissions
  • Loading branch information
misterdev committed May 3, 2019
1 parent d16404a commit 5284b7e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/cli.js
Expand Up @@ -326,14 +326,21 @@ For more information, see https://webpack.js.org/api/cli/.`);
const SIX_DAYS = 518400000;
const now = new Date();
if (now.getDay() === MONDAY) {
const { statSync, utimesSync } = require("fs");
const {
access,
constants,
statSync,
utimesSync,
} = require("fs");
const lastPrint = statSync(openCollectivePath).atime;
const lastPrintTS = new Date(lastPrint).getTime();
const timeSinceLastPrint = now.getTime() - lastPrintTS;
if (timeSinceLastPrint > SIX_DAYS) {
require(openCollectivePath);
// On windows we need to manually update the atime
utimesSync(openCollectivePath, now, now);
access(openCollectivePath, constants.W_OK, (e) => {
if (!e) utimesSync(openCollectivePath, now, now);
});
}
}
}
Expand Down

0 comments on commit 5284b7e

Please sign in to comment.