Skip to content

Commit d809862

Browse files
authored
Fallback to os temp directory if findCacheDir fail
From the readme: `Finds the cache dir using the supplied options. The algorithm tries to find a package.json file, searching every parent directory of the cwd specified (or implied from other options). It returns a string containing the absolute path to the cache directory, or null if package.json was never found.` This is a fallback for null condition. Investigated after @gaearon comments on facebook/create-react-app#1578 (comment)
1 parent 9e1025f commit d809862

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var crypto = require("crypto")
55
var fs = require("fs")
66
var findCacheDir = require("find-cache-dir")
77
var objectHash = require("object-hash")
8+
var os = require("os")
89

910
var engines = {}
1011
var cache = null
@@ -165,7 +166,7 @@ module.exports = function(input, map) {
165166
thunk: true,
166167
create: true,
167168
})
168-
cachePath = thunk("data.json")
169+
cachePath = thunk("data.json") || os.tmpdir() + '/data.json';
169170
try {
170171
cache = require(cachePath)
171172
}

0 commit comments

Comments
 (0)