1 | # hash-for-dep [![Build Status](https://travis-ci.org/stefanpenner/hash-for-dep.svg?branch=stuff)](https://travis-ci.org/stefanpenner/hash-for-dep) [![Build status](https://ci.appveyor.com/api/projects/status/wf2u3j6lc52hdd21?svg=true)](https://ci.appveyor.com/project/embercli/hash-for-dep)
|
2 |
|
3 | Generate a hash representing the stats of this module files and all its descendents files.
|
4 |
|
5 |
|
6 | ```js
|
7 | var hashForDep = require('hash-for-dep');
|
8 |
|
9 | hashForDep('rsvp'); // if RSVP is a dependency of the current project, you will get a checksum for it
|
10 | hashForDep('rsvp', 'path/to/other/project'); // you will get a checksum for RSVP resolved relative to the provided root
|
11 | ```
|
12 |
|
13 | ## Cache
|
14 |
|
15 | NOTE: By default, these hashes are cached for the life of the process. As this
|
16 | is the same strategy node uses for `require(x)` we can safely follow suite.
|
17 |
|
18 | That being said, some scenarios may exist where this is not wanted. So just
|
19 | like `require._cache` exists, we provide the following options:
|
20 |
|
21 | #### To evict the cache manually (maybe for testing)
|
22 |
|
23 | ```js
|
24 | require('hash-for-dep')._resetCache();
|
25 | ```
|
26 |
|
27 | #### To opt out of the cache on a per invocation basis
|
28 |
|
29 | ```js
|
30 | var hashForDep = require('hash-for-dep');
|
31 |
|
32 | hashForDep(name, path, null, false /* this mysterious argument should be set to false */);
|
33 | ```
|