folder-hash
Advanced tools
Comparing version 3.1.0 to 3.2.0
16
index.js
@@ -162,6 +162,6 @@ const crypto = require('crypto'), | ||
if (rules.exclude) { | ||
if (rules.matchBasename && rules.exclude.test(name)) { | ||
if (rules.matchBasename && rules.exclude(name)) { | ||
log.match(`exclude basename '${path}'`); | ||
return true; | ||
} else if (rules.matchPath && rules.exclude.test(path)) { | ||
} else if (rules.matchPath && rules.exclude(path)) { | ||
log.match(`exclude path '${path}'`); | ||
@@ -171,6 +171,6 @@ return true; | ||
} else if (rules.include) { | ||
if (rules.matchBasename && rules.include.test(name)) { | ||
if (rules.matchBasename && rules.include(name)) { | ||
log.match(`include basename '${path}'`); | ||
return false; | ||
} else if (rules.matchPath && rules.include.test(path)) { | ||
} else if (rules.matchPath && rules.include(path)) { | ||
log.match(`include path '${path}'`); | ||
@@ -286,9 +286,13 @@ return false; | ||
function reduceGlobPatterns(globs) { | ||
if (!globs || !Array.isArray(globs) || globs.length === 0) { | ||
if (typeof globs === 'function') { | ||
return globs; | ||
} | ||
else if (!globs || !Array.isArray(globs) || globs.length === 0) { | ||
return undefined; | ||
} else { | ||
// combine globs into one single RegEx | ||
return new RegExp(globs.reduce((acc, exclude) => { | ||
const regex = new RegExp(globs.reduce((acc, exclude) => { | ||
return acc + '|' + minimatch.makeRe(exclude).source; | ||
}, '').substr(1)); | ||
return param => regex.test(param); | ||
} | ||
@@ -295,0 +299,0 @@ } |
{ | ||
"name": "folder-hash", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Create a hash checksum over a folder and its content - its children and their content", | ||
@@ -30,3 +30,3 @@ "main": "index.js", | ||
"debug": "^4.1.1", | ||
"graceful-fs": "~4.1.11", | ||
"graceful-fs": "~4.2.0", | ||
"minimatch": "~3.0.4" | ||
@@ -37,6 +37,7 @@ }, | ||
"chai-as-promised": "^7.1.1", | ||
"jsdoc": "3.5.5", | ||
"ignore": "^5.1.2", | ||
"jsdoc": "3.6.3", | ||
"memfs": "^2.8.0", | ||
"mocha": "^6.0.2", | ||
"nyc": "^13.3.0" | ||
"nyc": "^14.1.1" | ||
}, | ||
@@ -43,0 +44,0 @@ "engines": { |
@@ -232,3 +232,3 @@ Create a hash checksum over a folder or a file. | ||
<td> | ||
<span>Array.<string></span> | ||
<span>Array.<string> || Function</span> | ||
</td> | ||
@@ -241,3 +241,3 @@ <td> | ||
</td> | ||
<td>Array of optional exclude glob patterns, see <a href="https://github.com/isaacs/minimatch#features">minimatch doc</a></td> | ||
<td>Array of optional exclude glob patterns, see <a href="https://github.com/isaacs/minimatch#features">minimatch doc</a>. Can also be a function which returns true if the passed file is excluded.</td> | ||
</tr> | ||
@@ -247,3 +247,3 @@ <tr> | ||
<td> | ||
<span>Array.<string></span> | ||
<span>Array.<string> || Function</span> | ||
</td> | ||
@@ -256,3 +256,3 @@ <td> | ||
</td> | ||
<td>Array of optional include glob patterns, see <a href="https://github.com/isaacs/minimatch#features">minimatch doc</a></td> | ||
<td>Array of optional include glob patterns, see <a href="https://github.com/isaacs/minimatch#features">minimatch doc</a>. Can also be a function which returns true if the passed file is included.</td> | ||
</tr> | ||
@@ -259,0 +259,0 @@ <tr> |
@@ -31,2 +31,25 @@ const path = require('path'); | ||
it('ignores things with an exclude function', function () { | ||
const hashElement = prep(Volume.fromJSON({ | ||
'abc/def': 'abc/def', | ||
'abc/ghi/jkl/file.js': 'content', | ||
'abc/ghi/jkl/file2.js': 'content', | ||
'abc/ghi/folder/data.json': 'content', | ||
'abc/ghi/folder/subfolder/today.log': 'content' | ||
})); | ||
const options = { | ||
folders: { | ||
exclude: path => path.includes('ghi') | ||
} | ||
}; | ||
const checkChildren = current => { | ||
current.children.length.should.equal(1); | ||
current.children[0].name.should.equal('def'); | ||
}; | ||
return hashElement('abc', options).then(checkChildren); | ||
}); | ||
it('generates different hashes if the folders have the same content but different names', function () { | ||
@@ -33,0 +56,0 @@ const hashElement = prep(Volume.fromJSON({ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
83816
31
990
7
1
+ Addedgraceful-fs@4.2.11(transitive)
- Removedgraceful-fs@4.1.15(transitive)
Updatedgraceful-fs@~4.2.0