Comparing version 1.0.3 to 1.0.4
@@ -54,3 +54,3 @@ 'use strict' | ||
deferred.resolve( | ||
hashFiles(files, options.algorithm) | ||
hashFiles(files, options) | ||
); | ||
@@ -57,0 +57,0 @@ } |
@@ -7,2 +7,3 @@ 'use strict' | ||
var q = require('q'); | ||
var path = require('path'); | ||
@@ -16,5 +17,5 @@ /** | ||
*/ | ||
module.exports = function(files, algorithm) { | ||
module.exports = function(files, options) { | ||
var deferred = q.defer(); | ||
var hash = crypto.createHash(algorithm); | ||
var hash = crypto.createHash(options.algorithm); | ||
var funcs = files.map(function(file) { | ||
@@ -26,2 +27,9 @@ return function(callback) { | ||
} else { | ||
if (options.filenames) { | ||
if (options.jail) { | ||
options.jail = path.resolve(options.jail); | ||
file = file.substr(options.jail.length + 1); | ||
} | ||
hash.update(file.replace(/\\/g,'/')); | ||
} | ||
hash.update(data); | ||
@@ -28,0 +36,0 @@ callback(); |
{ | ||
"name": "glob-hash", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "npm module to hash the contents of files matched by globs", | ||
@@ -5,0 +5,0 @@ "main": "lib/glob-hash.js", |
@@ -30,2 +30,3 @@ # glob-hash | ||
-j, --jail [path] A jail path. Reading outside the jail path will throw an error. | ||
-n, --filenames Include filenames in the hash. | ||
@@ -63,2 +64,4 @@ # Via API | ||
*Boolean* **filenames** - Include filename in the file hash. If used in combination with jail path, filename includes relative path from jail, otherwise it includes full path. | ||
### More samples | ||
@@ -65,0 +68,0 @@ ```js |
@@ -61,2 +61,10 @@ 'use strict' | ||
} | ||
}, { | ||
name: 'Should hash text files including filenames with jail path', | ||
result: '2aaea5813468828d7bb64d9c9a83f4ec4fae6cabccba6c733201fd2fa6e85b25', | ||
options: { | ||
include: ['**/*.tst'], | ||
filenames: true, | ||
jail: '.' | ||
} | ||
}]; | ||
@@ -63,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
17126
349
103