Permalink
Browse files

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

  • Loading branch information...
1 parent ebbc252 commit 6cbeff3dd7d0edb4d49ea301be1dce697d9e3c09 @irickt irickt committed Feb 15, 2012
Showing with 25 additions and 1 deletion.
  1. +9 −1 lib/map-path.js
  2. +16 −0 test/map-path.test.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);
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) {

0 comments on commit 6cbeff3

Please sign in to comment.