You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-45
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,37 @@
2
2
The hashes are propagated upwards, the hash that is returned for a folder is generated over all the hashes of its children.
3
3
The hashes are generated with the _sha1_ algorithm and returned in _base64_ encoding by default.
4
4
5
-
Each file returns a name and a hash, and each folder returns additionally an array of children (file or folder elements).
5
+
Each file returns a name and a hash, and each folder returns additionally an array of children (file or folder elements).
6
6
7
-
## Usage
8
-
First, install folder-hash with `npm install --save folder-hash` or `yarn add folder-hash`.
7
+
## Usage
8
+
9
+
First, install folder-hash with `npm install --save folder-hash` or `yarn add folder-hash`.
9
10
10
11
### Simple example
11
-
To see differences to the last version of this package, I would create hashes over all *.js* and *.json* files. But ignore everything inside folders starting with a dot, and also from the folders *node_modules*, *test_coverage*. The structure of the options object is documented <ahref="#options">below.</a>
12
-
This example is also stored in [./examples/readme-example1.js](/examples/readme-example1.js).
13
12
13
+
To see differences to the last version of this package, I would create hashes over all _.js_ and _.json_ files. But ignore everything inside folders starting with a dot, and also from the folders _node_modules_, _test_coverage_. The structure of the options object is documented <ahref="#options">below.</a>
14
+
This example is also stored in [./examples/readme-example1.js](/examples/readme-example1.js).
algo:'sha1', // see crypto.getHashes() for options
@@ -236,6 +243,7 @@ const options = {
236
243
</table>
237
244
238
245
#### Rules object properties
246
+
239
247
<table>
240
248
<thead>
241
249
<tr>
@@ -329,6 +337,7 @@ const options = {
329
337
</table>
330
338
331
339
### Symlink options
340
+
332
341
Configure, how symbolic links should be hashed.
333
342
To understand how the options can be combined to create a specific behavior, look into [test/symbolic-links.js](https://github.com/marc136/node-folder-hash/blob/master/test/symbolic-links.js).
334
343
@@ -396,11 +405,15 @@ To understand how the options can be combined to create a specific behavior, loo
396
405
</table>
397
406
398
407
## Command line usage
408
+
399
409
After installing it globally via
410
+
400
411
```
401
412
$ npm install -g folder-hash
402
413
```
414
+
403
415
You can use it like this:
416
+
404
417
```
405
418
# local folder
406
419
$ folder-hash -c config.json .
@@ -413,15 +426,19 @@ $ folder-hash /user/bin
413
426
It also allows to pass an optional JSON configuration file with the `-c` or `--config` flag, which should contain the same configuration as when using the JavaScript API.
414
427
415
428
You can also use a local version of folder-hash like this:
console.log('Result for folder "'+__dirname+'":');
493
-
console.log(hash.toString());
494
-
}
507
+
if (error) {
508
+
returnconsole.error('hashing failed:', error);
509
+
} else {
510
+
console.log('Result for folder "'+__dirname+'":');
511
+
console.log(hash.toString());
512
+
}
495
513
});
496
514
```
497
515
498
-
499
516
## Behavior
517
+
500
518
The behavior is documented and verified in the unit tests. Execute `npm test` or `mocha test`, and have a look at the _test_ subfolder.
501
519
You can also have a look at the [CircleCI report. ](https://circleci.com/gh/marc136/node-folder-hash/tree/master)
502
520
503
-
504
521
### Creating hashes over files (with default options)
522
+
505
523
**The hashes are the same if:**
506
524
507
525
- A file is checked again
@@ -514,6 +532,7 @@ You can also have a look at the [CircleCI report. 
535
+
517
536
Content means in this case a folder's children - both the files and the subfolders with their children.
518
537
519
538
**The hashes are the same if:**
@@ -528,4 +547,5 @@ Content means in this case a folder's children - both the files and the subfolde
528
547
- Two folders have the same content but different names
0 commit comments