How to use the cacache.rm function in cacache

To help you get started, we’ve selected a few cacache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xpack / xpm-js / lib / utils / xpack.js View on Github external
})
        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) {
      }
github npm / make-fetch-happen / cache.js View on Github external
'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)
  }
}
github JamieMason / shrinkpack / src / clear-cache.ts View on Github external
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);
};
github skypager / skypager / src / features / file-manager / src / file-manager.js View on Github external
'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, {
github mzgoddard / hard-source-webpack-plugin / lib / HardSourceCacacheSerializer.js View on Github external
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);
        }
      }),
    );
github npm / pacote / lib / fetcher.js View on Github external
cleanupCached () {
    return cacache.rm.content(this.cache, this.integrity, this.opts)
  }
github skypager / skypager / src / features / file-manager / src / file-manager.js View on Github external
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),
    }),
  }
}
github npm / pacote / lib / with-tarball-stream.js View on Github external
function cleanUpCached (cachePath, integrity, opts) {
  return cacache.rm.content(cachePath, integrity, opts)
}