How to use the package-hash function in package-hash

To help you get started, we’ve selected a few package-hash 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 novemberborn / hullabaloo-config-manager / test / hashDependencies.js View on Github external
test('hashes packages', async t => {
  const fromPackage = fixture('compare', 'node_modules', 'plugin')
  const filename = path.join(fromPackage, 'index.js')
  const hashed = await hashDependencies([
    {filename, fromPackage}
  ])
  t.deepEqual(hashed, [await packageHash(path.join(fromPackage, 'package.json'))])
})
github novemberborn / hullabaloo-config-manager / test / Verifier.js View on Github external
test.before(t => {
  const promises = []

  for (const pkg of [
    fixture('compare', 'node_modules', 'env-plugin', 'package.json'),
    fixture('compare', 'node_modules', 'plugin', 'package.json'),
    fixture('compare', 'node_modules', 'plugin-copy', 'package.json'),
    fixture('compare', 'node_modules', 'plugin-default-opts', 'package.json'),
    fixture('compare', 'node_modules', 'preset', 'package.json')
  ]) {
    promises.push(
      packageHash(pkg)
        .then(hash => (hashes[pkg] = hash)))
  }

  for (const fp of [
    fixture('compare', '.babelrc'),
    fixture('compare', 'dir', 'subdir', 'extended-by-babelrc.js'),
    fixture('compare', 'extended-by-virtual.json5'),
    fixture('compare', 'dir', 'extended-by-virtual-foo.json5'),
    fixture('compare', 'virtual.json')
  ]) {
    promises.push(
      new Promise((resolve, reject) => {
        fs.readFile(fp, (err, contents) => err ? reject(err) : resolve(contents))
      })
        .then(md5Hex)
        .then(hash => (hashes[fp] = hash)))

package-hash

Generates a hash for an installed npm package, useful for salting caches

ISC
Latest version published 5 years ago

Package Health Score

68 / 100
Full package analysis

Popular package-hash functions

Similar packages