Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const cachePath = getCachePath();
const cacheFile = path.join(cachePath, CacheFileName);
if (!fs.existsSync(cacheFile)) {
return false;
}
let shouldCache = false;
try {
const cachedHash = JSON.parse(fs.readFileSync(path.join(cachePath, CacheFileName)).toString());
// TODO: make a more robust comparison
shouldCache = JSON.stringify(currentHash) === JSON.stringify(cachedHash);
} catch (e) {
logger.warn('Invalid package-deps.json detected');
}
return shouldCache;
}