folder-hash
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "folder-hash", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Create a hash checksum over a folder and its content - its children and their content", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"cover": "node node_modules/istanbul/lib/cli.js cover --dir test_coverage node_modules/mocha/bin/_mocha test", | ||
"doc": "./node_modules/.bin/jsdoc index.js" | ||
"doc": "./node_modules/.bin/jsdoc index.js -R README.md -d doc" | ||
}, | ||
@@ -23,9 +23,9 @@ "author": { | ||
"dependencies": { | ||
"graceful-fs": "^4.1.11", | ||
"minimatch": "^3.0.3", | ||
"when": "^3.7.7" | ||
"graceful-fs": "~4.1.11", | ||
"minimatch": "~3.0.4", | ||
"when": "~3.7.8" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"chai": "^4.0.2", | ||
"chai-as-promised": "^7.1.1", | ||
"istanbul": "^0.4.5", | ||
@@ -32,0 +32,0 @@ "jsdoc": "^3.4.3", |
119
README.md
@@ -1,5 +0,2 @@ | ||
# folderHash | ||
## Description | ||
Create a hash checksum over a folder or a file. | ||
Create a hash checksum over a folder or a file. | ||
The hashes are propagated upwards, the hash that is returned for a folder is generated over all the hashes of its children. | ||
@@ -10,13 +7,15 @@ The hashes are generated with the _sha1_ algorithm and returned in _base64_ encoding. | ||
{ name: 'test', | ||
hash: 'qmUXLCsTQGOEF6p0w9V78MC7sJI=', | ||
children: [ | ||
{ name: 'helper', | ||
hash: 'x1CX3yVH3UuLTw7zcSitSs/PbGE=', | ||
children: [ | ||
{ name: 'helper.js', hash: 'pHYwd8k/oZV01oABTz9MC8KovkU=' } | ||
] }, | ||
{ name: 'test.js', hash: 'L/vqpdQhxmD5w62k24m4TuZJ1PM=' } | ||
] | ||
} | ||
```js | ||
{ name: 'test', | ||
hash: 'qmUXLCsTQGOEF6p0w9V78MC7sJI=', | ||
children: [ | ||
{ name: 'helper', | ||
hash: 'x1CX3yVH3UuLTw7zcSitSs/PbGE=', | ||
children: [ | ||
{ name: 'helper.js', hash: 'pHYwd8k/oZV01oABTz9MC8KovkU=' } | ||
] }, | ||
{ name: 'test.js', hash: 'L/vqpdQhxmD5w62k24m4TuZJ1PM=' } | ||
] | ||
} | ||
``` | ||
@@ -26,50 +25,54 @@ Each file returns a name and a hash, and each folder returns additionally an array of children (file or folder elements). | ||
## Usage | ||
First, install the dependencies by executing `npm install`. | ||
First, install folder-hash with `npm install --save folder-hash`. | ||
### With promises | ||
var hasher = require('folder-hash'); | ||
// pass element name and folder path separately | ||
hasher.hashElement('node_modules', __dirname).then(function (hash) { | ||
console.log('Result for folder "node_modules" in directory "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass element path directly | ||
hasher.hashElement(__dirname).then(function (hash) { | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass options (example: exclude dotFiles) | ||
var options = { excludes: ['.*'], match: { basename: true, path: false } }; | ||
hasher.hashElement(__dirname, options, function (error, hash)) { | ||
if (error) return console.error('hashing failed:', error); | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
```js | ||
var hasher = require('folder-hash'); | ||
// pass element name and folder path separately | ||
hasher.hashElement('node_modules', __dirname).then(function (hash) { | ||
console.log('Result for folder "node_modules" in directory "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass element path directly | ||
hasher.hashElement(__dirname).then(function (hash) { | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass options (example: exclude dotFiles) | ||
var options = { excludes: ['.*'], match: { basename: true, path: false } }; | ||
hasher.hashElement(__dirname, options) | ||
.then(function (hash) { | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}) | ||
.catch(function (error) { | ||
return console.error('hashing failed:', error); | ||
}); | ||
``` | ||
### With callbacks | ||
var hasher = require('folder-hash'); | ||
// pass element name and folder path separately | ||
hasher.hashElement('node_modules', __dirname, function (error, hash)) { | ||
if (error) return console.error('hashing failed:', error); | ||
console.log('Result for folder "node_modules" in directory "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass element path directly | ||
hasher.hashElement(__dirname, function (error, hash)) { | ||
if (error) return console.error('hashing failed:', error); | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass options (example: exclude dotFiles) | ||
var options = { excludes: ['**/.*'], match: { basename: false, path: true } }; | ||
hasher.hashElement(__dirname, options, function (error, hash)) { | ||
if (error) return console.error('hashing failed:', error); | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
```js | ||
var hasher = require('folder-hash'); | ||
// pass element name and folder path separately | ||
hasher.hashElement('node_modules', __dirname, function (error, hash) { | ||
if (error) return console.error('hashing failed:', error); | ||
console.log('Result for folder "node_modules" in directory "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass element path directly | ||
hasher.hashElement(__dirname, function (error, hash) { | ||
if (error) return console.error('hashing failed:', error); | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
// pass options (example: exclude dotFiles) | ||
var options = { excludes: ['**/.*'], match: { basename: false, path: true } }; | ||
hasher.hashElement(__dirname, options, function (error, hash) { | ||
console.log('Result for folder "' + __dirname + '":'); | ||
console.log(hash.toString()); | ||
}); | ||
``` | ||
### Parameters for the hashElement function | ||
@@ -228,3 +231,3 @@ | ||
### Creating hashes over folders | ||
Content means in this case a folders children - both the files and the subfolders with their children. | ||
Content means in this case a folder's children - both the files and the subfolders with their children. | ||
@@ -243,2 +246,2 @@ **The hashes are the same if:** | ||
## License | ||
MIT, see LICENSE.txt | ||
MIT, see LICENSE.txt |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2148142
18
709
244
1
1
+ Addedgraceful-fs@4.1.15(transitive)
+ Addedminimatch@3.0.8(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedminimatch@3.1.2(transitive)
Updatedgraceful-fs@~4.1.11
Updatedminimatch@~3.0.4
Updatedwhen@~3.7.8