Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pass a fileList in params and get hashMap for the list. test.

  • Loading branch information...
commit 6cbeff3dd7d0edb4d49ea301be1dce697d9e3c09 1 parent ebbc252
Rick Thomas irickt authored
Showing with 25 additions and 1 deletion.
  1. +9 −1 lib/map-path.js
  2. +16 −0 test/map-path.test.js
10 lib/map-path.js
View
@@ -41,7 +41,6 @@ module.exports = function(dirPath, params, callback) {
}
function makeHashMap (callback) {
-
var hashMap = Object.create(null);
async.forEach(files, function(filename, fileCallback) {
hash(filename, function(error, fileHash) {
@@ -64,6 +63,15 @@ module.exports = function(dirPath, params, callback) {
});
}
+ if (options.fileList) {
+ for (var i in options.fileList) {
+ files.push(options.fileList[i]);
+ }
+ makeHashMap(callback);
+ return;
+ }
+ // else
+
walker(dirPath)
.on('file', function(filename) {
files.push(filename);
16 test/map-path.test.js
View
@@ -73,6 +73,22 @@ describe('versionator', function() {
});
+ it('should accept fileList and create hashes', function(done) {
+ var fileList = [
+ tmpPath + '/c',
+ tmpPath + '/sub/a'
+ ]
+ versionator.createMapFromPath(tmpPath, {'fileList': fileList}, function(error, results) {
+
+ var a = {
+ '/c': '/e509465ef513154988e088d6ad3c21bf/c',
+ '/sub/a': '/sub/49f68a5c8493ec2c0bf489821c21fc3b/a' }.should.eql(results);
+
+ done();
+ });
+
+ });
+
});
after(function(done) {
Please sign in to comment.
Something went wrong with that request. Please try again.