{"name":"package-hash","version":"1.2.0","description":"Generates a hash for an installed npm package, useful for salting caches","main":"index.js","files":["index.js","index.js.map"],"scripts":{"clean":"rimraf index.js index.js.map","prebuild":"npm run clean","build":"babel src --out-dir ./ --source-maps","prepublish":"npm run build","lint":"as-i-preach","unpack-fixtures":"node scripts/unpack-fixtures.js","pregenerate-fixture-index":"npm run unpack-fixtures","generate-fixture-index":"node scripts/generate-fixture-index.js","pretest":"npm run unpack-fixtures","test":"ava","posttest":"npm run lint","coverage":"nyc npm test","watch:build":"npm run build -- --watch","watch:test":"npm run test -- --watch"},"repository":{"type":"git","url":"git+https://github.com/novemberborn/package-hash.git"},"author":{"name":"Mark Wubben","url":"https://novemberborn.net/"},"license":"ISC","bugs":{"url":"https://github.com/novemberborn/package-hash/issues"},"homepage":"https://github.com/novemberborn/package-hash#readme","dependencies":{"md5-hex":"^1.3.0"},"devDependencies":{"@novemberborn/as-i-preach":"^2.0.1","ava":"^0.14.0","babel-cli":"^6.7.5","babel-plugin-transform-es2015-block-scoping":"^6.7.1","babel-plugin-transform-es2015-modules-commonjs":"^6.7.4","babel-plugin-transform-es2015-shorthand-properties":"^6.5.0","babel-plugin-transform-object-assign":"^6.5.0","babel-plugin-transform-strict-mode":"^6.6.5","nyc":"^6.4.0","proxyquire":"^1.7.4","rimraf":"^2.5.2","tar":"^2.2.1"},"babel":{"plugins":["transform-object-assign","transform-es2015-block-scoping","transform-es2015-modules-commonjs","transform-es2015-shorthand-properties","transform-strict-mode"]},"nyc":{"cache":true,"exclude":["scripts","test"],"reporter":["html","lcov","text"]},"gitHead":"2a14f0f767017f941aab62cd44c3c14689f6b843","_id":"package-hash@1.2.0","_shasum":"003e56cd57b736a6ed6114cc2b81542672770e44","_from":".","_npmVersion":"3.8.7","_nodeVersion":"5.10.1","_npmUser":{"name":"novemberborn","email":"mark@novemberborn.net"},"dist":{"shasum":"003e56cd57b736a6ed6114cc2b81542672770e44","tarball":"http://registry-npm.ywwl.com/package-hash/download/package-hash-1.2.0.tgz","integrity":"sha512-W5ILqaI3G6bXDuYb7TrQ95TFHfFdjiunpp61PAXj7z32TgJ5NIBaoqZVI6AXUQy/qcqPoFnz0hAZY9KyKd4xNA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDH+wixZQyqIViYHE+YtZBV/gj75asUA9eLOzPmaBPl9gIhAMtOZMeDHdTdBZzTNxgKoIZ7CyMHT9RaUYXLI2cJXUkj"}],"size":5434,"noattachment":false,"key":"/package-hash/-/package-hash-1.2.0.tgz"},"maintainers":[{"name":"novemberborn","email":"mark@novemberborn.net"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/package-hash-1.2.0.tgz_1463403606290_0.8582867733202875"},"directories":{},"readme":"# package-hash\n\nGenerates a hash for an installed npm package, useful for salting caches.\n[AVA](https://github.com/sindresorhus/ava) for example caches precompiled test\nfiles. It generates a salt for its cache based on the various packages that are\nused when compiling the test files.\n\n`package-hash` can generate an appropriate hash based on the package location\n(on disk) and the `package.json` file. This hash is salted with a hash\nfor the `package-hash` itself.\n\n`package-hash` can detect when the package-to-be-hashed is a Git repository. In\nthe AVA example this is useful when you're debugging one of the packages used to\ncompile the test files. You can clone it locally and use `npm link` so AVA can\nfind the clone. The hash will include the HEAD (`.git/HEAD`) and its\ncorresponding ref (e.g. `.git/refs/heads/master`), any packed refs\n(`.git/packed-refs`), as well as the diff (`git diff`) for any non-committed\nchanges. This makes it really easy to test your changes without having to\nexplicitly clear the cache in the parent project.\n\n## Installation\n\n```console\n$ npm install --save package-hash\n```\n\n## Usage\n\n```js\nconst packageHash = require('package-hash')\n\n// Asynchronously:\nconst hash = await packageHash(require.resolve('babel-core/package.json'))\n\n// Synchronously:\nconst hash = packageHash.sync(require.resolve('babel-core/package.json'))\n```\n\n`packageHash()` / `packageHash.sync()` must be called with a file path for an\nexisting `package.json` file. To get the path to an npm package it's easiest to\nuse `require.resolve('the-name/package.json')`.\n\nYou can provide multiple paths:\n\n```js\nconst hash = await packageHash([\n  require.resolve('babel-core/package.json'),\n  require.resolve('babel-preset-es2015/package.json')\n])\n```\n\nAn optional salt value can also be provided:\n\n```js\nconst hash = await packageHash(require.resolve('babel-core/package.json'), 'salt value')\n```\n\n## API\n\n### `packageHash(paths, salt?)`\n\n`paths: string | string[]` ➜ can be a single file path, or an array of paths.\n\n`salt: Array | Buffer | Object | string` ➜ optional. If an `Array` or `Object` (not `null`) it is first converted to a JSON string.\n\nReturns a promise for the hex-encoded hash string.\n\n### `packageHash.sync(paths, salt?)`\n\n`paths: string | string[]` ➜ can be a single file path, or an array of paths.\n\n`salt: Array | Buffer | Object | string` ➜ optional. If an `Array` or `Object` (not `null`) it is first converted to a JSON string.\n\nReturns a hex-encoded hash string.\n\n## Compatibility\n\n`package-hash` has been tested with Node.js 8 and above, including Windows\nsupport.\n","publish_time":1463403608288,"_cnpm_publish_time":1463403608288,"dist-tags":{"latest":"4.0.0"}}