Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
log.trace(integrity)
if (integrity[hashAlgorithm][0].source !== integrityDigest) {
throw new Error('Integrity check failed')
} else {
log.trace('integrity digest ok')
}
} catch (err) {
// Do not throw yet, only display the error.
log.info(err)
if (os.platform() === 'win32') {
log.info('If you have an aggressive antivirus, try to' +
' reconfigure it, or temporarily disable it.')
}
// Remove from the index.
await cacache.rm.entry(cachePath, cacheKey)
throw new CliError('Download failed.', CliExitCodes.ERROR.INPUT)
}
// Update the cache info after downloading the file.
cacheInfo = await cacache.get.info(cachePath, cacheKey)
if (!cacheInfo) {
throw new CliError('Download failed.', CliExitCodes.ERROR.INPUT)
}
}
// The number of initial folder levels to skip.
let skip = 0
if (json.xpack.binaries.skip) {
try {
skip = parseInt(json.xpack.binaries.skip)
} catch (err) {
}
'delete' (req, opts) {
opts = opts || {}
if (typeof opts.memoize === 'object') {
if (opts.memoize.reset) {
opts.memoize.reset()
} else if (opts.memoize.clear) {
opts.memoize.clear()
} else {
Object.keys(opts.memoize).forEach(k => {
opts.memoize[k] = null
})
}
}
return cacache.rm.entry(
this._path,
cacheKey(req)
// TODO - true/false
).then(() => false)
}
}
const clearCache = async () => {
const UTF8 = { encoding: 'utf8' };
const { stdout: pathToCache } = await exec('npm config get cache', UTF8);
const pathToCacache = path.join(pathToCache, '_cacache');
await cacache.rm.all(pathToCacache);
};
'node_modules',
'.cache',
'skypager-cache'
)
const {
fileManagerCachePath,
skypagerCachePath = fileManagerCachePath || defaultCachePath,
} = options
const arg = fn => partial(fn, this.runtime.resolve(skypagerCachePath))
const ls = arg(cacache.ls)
const get = arg(cacache.get)
const put = arg(cacache.put)
const rm = arg(cacache.rm)
const verify = arg(cacache.verify)
return {
...cacache,
cachePath: skypagerCachePath,
ls: Object.assign(ls, {
stream: arg(cacache.ls.stream),
}),
get: Object.assign(get, {
stream: arg(cacache.get.stream),
byDigest: arg(cacache.get.byDigest),
copy: arg(cacache.get.copy),
info: arg(cacache.get.info),
hasContent: arg(cacache.get.hasContent),
}),
put: Object.assign(put, {
ops.map(op => {
if (op.value) {
return cacache.put(this.path, op.key, JSON.stringify(op.value));
} else {
return cacache.rm.entry(this.path, op.key);
}
}),
);
cleanupCached () {
return cacache.rm.content(this.cache, this.integrity, this.opts)
}
ls: Object.assign(ls, {
stream: arg(cacache.ls.stream),
}),
get: Object.assign(get, {
stream: arg(cacache.get.stream),
byDigest: arg(cacache.get.byDigest),
copy: arg(cacache.get.copy),
info: arg(cacache.get.info),
hasContent: arg(cacache.get.hasContent),
}),
put: Object.assign(put, {
stream: arg(cacache.put.stream),
}),
rm: Object.assign(rm, {
all: arg(cacache.rm.all),
entry: arg(cacache.rm.entry),
content: arg(cacache.rm.content),
}),
tmp: {
mkdir: arg(cacache.tmp.mkdir),
withTmp: arg(cacache.tmp.withTmp),
},
verify: Object.assign(verify, {
lastRun: arg(cacache.verify.lastRun),
}),
}
}
function cleanUpCached (cachePath, integrity, opts) {
return cacache.rm.content(cachePath, integrity, opts)
}