From 5284b7e97cb8450d479d8220d09222103871ef72 Mon Sep 17 00:00:00 2001 From: Devid Farinelli Date: Fri, 3 May 2019 16:59:44 +0200 Subject: [PATCH] fix(opencollective-prompt): check write permissions --- bin/cli.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index aa7df4c2d9c..3819cda71a0 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -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); + }); } } }