Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,36 @@ | ||
{ | ||
"name": "hashd", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "hash all the files recursively from a specified path, appreciate .ignore files. uses `sha1` by default.", | ||
"main": "index.js", | ||
"bin": "./bin/hashd", | ||
"author": "", | ||
"bin": { | ||
"hashd": "./bin/hashd" | ||
}, | ||
"license": "MIT", | ||
"author": "Paolo Fragomeni <paolo@async.ly> (http://twitter.com/hij1nx)", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/hij1nx/hashd.git" | ||
}, | ||
"dependencies": { | ||
"optimist": "~0.6.0", | ||
"minimatch": "~0.2.12", | ||
"uniq": "0.0.2" | ||
} | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hij1nx/hashd/issues" | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "node ./test/test.js" | ||
}, | ||
"keywords": [ | ||
"hash", | ||
"recursive", | ||
"file", | ||
"tree" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var assert = require('assert') | ||
var path = require('path') | ||
var hashd = require('../index') | ||
|
||
var basepath = path.join(__dirname, 'fixtures') | ||
console.log('\nhasing %s', basepath) | ||
var basehash = hashd(basepath) | ||
|
||
var pathA = path.join(basepath, 'a') | ||
console.log('\nhasing %s', pathA) | ||
var hashA = hashd(pathA) | ||
|
||
var pathB = path.join(basepath, 'b') | ||
console.log('\nhasing %s', pathB) | ||
var hashB = hashd(pathB) | ||
|
||
assert.notEqual(basehash, hashA) | ||
assert.notEqual(basehash, hashB) | ||
assert.notEqual(hashB, hashA) | ||
|
||
var ignorePattern1 = ["a", ".ignore-a", ".ignore-b"] | ||
console.log('\nhashing %s (patterns: %j)', basepath, ignorePattern1) | ||
|
||
var basehashIgnorePatternA = hashd(basepath, { patterns: ignorePattern1 }) | ||
assert.notEqual(basehash, basehashIgnorePatternA, 'The base hash should be different from the hash that excludes directory `A`.') | ||
assert.equal(basehashIgnorePatternA, hashB, 'The hash excluding directory `A` should be the same as the hash on directory `B`.') | ||
|
||
var ignorePattern2 = ["b", ".ignore-a", ".ignore-b"] | ||
console.log('\nhashing %s (patterns: %j)', basepath, ignorePattern2) | ||
|
||
var basehashIgnorePatternB = hashd(basepath, { patterns: ignorePattern2 }) | ||
assert.notEqual(basehash, basehashIgnorePatternB, 'The base hash should be different from the hash that excludes directory `B`.') | ||
assert.equal(basehashIgnorePatternB, hashA, 'The hash excluding directory `B` should be the same as the hash on directory `A`.') | ||
|
||
var ignoreFiles1 = ['.ignore-a'] | ||
var ignorePattern3 = ['.ignore-b', '.ignore-a'] // use a file's globs but also ignore the file itself | ||
console.log('\nhashing %s (patterns: %j, files: %j)', basepath, ignoreFiles1, ignorePattern3) | ||
|
||
var basehashIgnoreFileA = hashd(basepath, { files: ignoreFiles1, patterns: ignorePattern3 }) | ||
assert.notEqual(basehash, basehashIgnoreFileA, 'The base hash should be different from the hash that excludes directory `A`.') | ||
assert.equal(basehashIgnoreFileA, hashB, 'The hash excluding directory `A` should be the same as the hash on directory `B`.') |