From 0e59c5a742513839af2cfbd5e305afe18b3d800f Mon Sep 17 00:00:00 2001 From: Cuki <2996147+cuki@users.noreply.github.com> Date: Thu, 4 Jul 2019 12:26:28 +0200 Subject: [PATCH] Fix: Cache file error handling on read-only file system. (fixes #11945) --- lib/cli-engine/cli-engine.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cli-engine/cli-engine.js b/lib/cli-engine/cli-engine.js index 81e1b07c83e..671a389ad4b 100644 --- a/lib/cli-engine/cli-engine.js +++ b/lib/cli-engine/cli-engine.js @@ -734,7 +734,10 @@ class CLIEngine { try { fs.unlinkSync(cacheFilePath); } catch (error) { - if (!error || error.code !== "ENOENT") { + const errorCode = error && error.code; + + // Ignore errors when no such file exists or file system is read only (and cache file does not exist) + if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) { throw error; } }