Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # package-hash
  2. Generates a hash for an installed npm package, useful for salting caches.
  3. [AVA](https://github.com/sindresorhus/ava) for example caches precompiled test
  4. files. It generates a salt for its cache based on the various packages that are
  5. used when compiling the test files.
  6. `package-hash` can generate an appropriate hash based on the package location
  7. (on disk) and the `package.json` file. This hash is salted with a hash
  8. for the `package-hash` itself.
  9. `package-hash` can detect when the package-to-be-hashed is a Git repository. In
  10. the AVA example this is useful when you're debugging one of the packages used to
  11. compile the test files. You can clone it locally and use `npm link` so AVA can
  12. find the clone. The hash will include the HEAD (`.git/HEAD`) and its
  13. corresponding ref (e.g. `.git/refs/heads/master`), any packed refs
  14. (`.git/packed-refs`), as well as the diff (`git diff`) for any non-committed
  15. changes. This makes it really easy to test your changes without having to
  16. explicitly clear the cache in the parent project.
  17. ## Installation
  18. ```console
  19. $ npm install --save package-hash
  20. ```
  21. ## Usage
  22. ```js
  23. const packageHash = require('package-hash')
  24. // Asynchronously:
  25. const hash = await packageHash(require.resolve('babel-core/package.json'))
  26. // Synchronously:
  27. const hash = packageHash.sync(require.resolve('babel-core/package.json'))
  28. ```
  29. `packageHash()` / `packageHash.sync()` must be called with a file path for an
  30. existing `package.json` file. To get the path to an npm package it's easiest to
  31. use `require.resolve('the-name/package.json')`.
  32. You can provide multiple paths:
  33. ```js
  34. const hash = await packageHash([
  35. require.resolve('babel-core/package.json'),
  36. require.resolve('babel-preset-es2015/package.json')
  37. ])
  38. ```
  39. An optional salt value can also be provided:
  40. ```js
  41. const hash = await packageHash(require.resolve('babel-core/package.json'), 'salt value')
  42. ```
  43. ## API
  44. ### `packageHash(paths, salt?)`
  45. `paths: string | string[]` ➜ can be a single file path, or an array of paths.
  46. `salt: Array | Buffer | Object | string` ➜ optional. If an `Array` or `Object` (not `null`) it is first converted to a JSON string.
  47. Returns a promise for the hex-encoded hash string.
  48. ### `packageHash.sync(paths, salt?)`
  49. `paths: string | string[]` ➜ can be a single file path, or an array of paths.
  50. `salt: Array | Buffer | Object | string` ➜ optional. If an `Array` or `Object` (not `null`) it is first converted to a JSON string.
  51. Returns a hex-encoded hash string.
  52. ## Compatibility
  53. `package-hash` has been tested with Node.js 8 and above, including Windows
  54. support.