Skip to content

Commit

Permalink
Fallback to os temp directory if findCacheDir fail
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
viankakrisna committed Feb 17, 2017
1 parent 9e1025f commit d809862
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var crypto = require("crypto")
var fs = require("fs")
var findCacheDir = require("find-cache-dir")
var objectHash = require("object-hash")
var os = require("os")

var engines = {}
var cache = null
Expand Down Expand Up @@ -165,7 +166,7 @@ module.exports = function(input, map) {
thunk: true,
create: true,
})
cachePath = thunk("data.json")
cachePath = thunk("data.json") || os.tmpdir() + '/data.json';
try {
cache = require(cachePath)
}
Expand Down

0 comments on commit d809862

Please sign in to comment.