Skip to content

Commit 5284b7e

Browse files
committed
fix(opencollective-prompt): check write permissions
1 parent d16404a commit 5284b7e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

bin/cli.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,21 @@ For more information, see https://webpack.js.org/api/cli/.`);
326326
const SIX_DAYS = 518400000;
327327
const now = new Date();
328328
if (now.getDay() === MONDAY) {
329-
const { statSync, utimesSync } = require("fs");
329+
const {
330+
access,
331+
constants,
332+
statSync,
333+
utimesSync,
334+
} = require("fs");
330335
const lastPrint = statSync(openCollectivePath).atime;
331336
const lastPrintTS = new Date(lastPrint).getTime();
332337
const timeSinceLastPrint = now.getTime() - lastPrintTS;
333338
if (timeSinceLastPrint > SIX_DAYS) {
334339
require(openCollectivePath);
335340
// On windows we need to manually update the atime
336-
utimesSync(openCollectivePath, now, now);
341+
access(openCollectivePath, constants.W_OK, (e) => {
342+
if (!e) utimesSync(openCollectivePath, now, now);
343+
});
337344
}
338345
}
339346
}

0 commit comments

Comments
 (0)