How to use the cacache.put 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 npm / tink / test / pkgmap.js View on Github external
test('stat: get filesystem stats for a file', async t => {
  const cacheDir = path.join(testDir.path, '_cacache')
  const hash = await cacache.put(cacheDir, 'eggplant:hello', 'hello world')
  process.tink = {
    cache: cacheDir
  }
  const fixture = new Tacks(Dir({
    '.package-map.json': File({
      path_prefix: '/node_modules',
      packages: {
        'eggplant': {
          files: {
            'hello.js': hash
          }
        }
      }
    })
  }))
  fixture.create(testDir.path)
github entropic-dev / entropic / cli / lib / fetch-package.js View on Github external
.then(xs => JSON.parse(String(xs.data)))
    .catch(() => null);

  if (!meta || now - Date.parse(meta.date) > Number(expires)) {
    const pkgReq = await fetch(`${registry}/v1/packages/package/${name}`);
    meta = {
      date: Date.parse(pkgReq.headers.date),
      data: await pkgReq.json()
    };

    if (pkgReq.status > 399) {
      console.log(name, meta.data);
      throw new Error();
    }

    await cacache.put(cache, `spackage:${name}`, JSON.stringify(meta));
  }

  return meta.data;
}
github graalvm / graaljs / graal-nodejs / deps / npm / node_modules / pacote / lib / fetchers / file.js View on Github external
return readFileAsync(src).then(data => {
          if (opts.cache) {
            return cacache.put(
              opts.cache, `pacote:tarball:file:${src}`, data, {
                integrity: opts.integrity
              }
            ).then(integrity => ({ data, integrity }))
          } else {
            return { data }
          }
        }).then(info => {
          if (info.integrity) { stream.emit('integrity', info.integrity) }
github npm / pacote / lib / fetchers / file.js View on Github external
return readFileAsync(src).then(data => {
          if (opts.cache) {
            return cacache.put(
              opts.cache, `pacote:tarball:file:${src}`, data, {
                integrity: opts.integrity
              }
            ).then(integrity => ({ data, integrity }))
          } else {
            return { data }
          }
        }).then(info => {
          if (info.integrity) { stream.emit('integrity', info.integrity) }
github angular / angular-cli / packages / angular_devkit / build_angular / src / utils / process-bundle.ts View on Github external
async function cachePut(content: string, key: string | null, integrity?: string): Promise {
  if (cachePath && key) {
    await cacache.put(cachePath, key, content, {
      metadata: { integrity },
    });
  }
}
github npm / pacote / lib / finalize-manifest.js View on Github external
}).then(manifest => {
        const cacheKey = key || finalKey(manifest, spec)
        if (!opts.cache || !cacheKey) {
          return manifest
        } else {
          return cacache.put(
            opts.cache, cacheKey, '.', {
              metadata: {
                id: manifest._id,
                manifest,
                type: 'finalized-manifest'
              }
            }
          ).then(() => manifest)
        }
      })
    }
github metalabdesign / sharp-loader / src / sharp.js View on Github external
return generatedImage.then((result) => {
      if (typeof globalOptions.cacheDir === 'string') {
        return Promise.all([
          cacache.put(globalOptions.cacheDir, bufferCacheKey, result.buffer),
          cacache.put(
            globalOptions.cacheDir,
            metaCacheKey,
            JSON.stringify(result.info),
          ),
        ]).then(() => result);
      }
      return result;
    });
  });
github nrwl / nx / packages / web / src / utils / third-party / utils / process-bundle.ts View on Github external
async function cachePut(
  content: string,
  key: string | null,
  integrity?: string
): Promise {
  if (cachePath && key) {
    await cacache.put(cachePath, key, content, {
      metadata: { integrity }
    });
  }
}
github metalabdesign / sharp-loader / src / sharp.js View on Github external
return generatedImage.then((result) => {
      if (typeof globalOptions.cacheDir === 'string') {
        return Promise.all([
          cacache.put(globalOptions.cacheDir, bufferCacheKey, result.buffer),
          cacache.put(
            globalOptions.cacheDir,
            metaCacheKey,
            JSON.stringify(result.info),
          ),
        ]).then(() => result);
      }
      return result;
    });
  });
github npm / make-fetch-happen / cache.js View on Github external
collecter.on('collect', data => {
        cacache.put(
          cachePath,
          ckey,
          data,
          cacheOpts
        ).then(cacheWriteResolve, cacheWriteReject)
      })
      newBody.unshift(collecter)