Handle missing cache directory for changedCache (#6327)
* handle missing cache directory for changedCache * fallback to temp dir when cache dir not foundmaster
parent
6fae09b67e
commit
48697e9237
|
@ -9,6 +9,7 @@ const chalk = require("chalk");
|
|||
const readline = require("readline");
|
||||
const stringify = require("json-stable-stringify");
|
||||
const findCacheDir = require("find-cache-dir");
|
||||
const os = require("os");
|
||||
|
||||
const minimist = require("./minimist");
|
||||
const prettier = require("../../index");
|
||||
|
@ -445,7 +446,9 @@ function formatFiles(context) {
|
|||
|
||||
let changedCache = null;
|
||||
if (context.argv["only-changed"]) {
|
||||
const cacheDir = findCacheDir({ name: "prettier", create: true });
|
||||
const cacheDir =
|
||||
findCacheDir({ name: "prettier", create: true }) || os.tmpdir();
|
||||
|
||||
changedCache = new ChangedCache({
|
||||
location: path.join(cacheDir, "changed"),
|
||||
readFile: fs.readFileSync,
|
||||
|
|
Loading…
Reference in New Issue