Comparing version 0.1.15 to 0.1.16
42
index.js
@@ -128,31 +128,21 @@ var fs = require("fs"); | ||
var self = this; | ||
var baseDirectory = self.config.bucket + (options.prefix || '/'); | ||
utils.checkToPath(baseDirectory, function() { | ||
var walk = require("walk"); | ||
var walker = walk.walk(baseDirectory); | ||
var files = []; | ||
async.waterfall([ | ||
function (cb) { | ||
if (!options.prefix) { | ||
options.prefix = "/"; | ||
} | ||
cb(); | ||
}, | ||
function (cb) { | ||
utils.checkToPath(self.config.bucket + options.prefix, function () { | ||
cb(); | ||
walker.on("file", function (root, stat, next) { | ||
files.push({ | ||
Key: join(relative(self.config.bucket, root), stat.name), | ||
Size: stat.size, | ||
LastModified: stat.mtime | ||
}); | ||
}, | ||
function (cb) { | ||
var walk = require("walk"); | ||
var walker = walk.walk(self.config.bucket + options.prefix); | ||
var files = []; | ||
next(); | ||
}); | ||
walker.on("file", function (root, stat, next) { | ||
var directory = relative(self.config.bucket, root); | ||
files.push({Key: join(directory, stat.name)}); | ||
next(); | ||
}); | ||
walker.on("end", function () { | ||
cb(null, {Contents: files}); | ||
}); | ||
} | ||
], cb); | ||
walker.on("end", function () { | ||
cb(null, {Contents: files}); | ||
}); | ||
}); | ||
}; | ||
@@ -159,0 +149,0 @@ |
{ | ||
"name": "faux-knox", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Mock requests to knox module using file system", | ||
"main": "index.js", | ||
"registry": "https://registry.npmjs.org/", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "test": "./node_modules/.bin/mocha" |
24
test.js
@@ -147,5 +147,7 @@ var should = require("should"); | ||
if (err) return done(err); | ||
page.Contents.should.eql([ | ||
{Key: "list/one"}, {Key: "list/two"} | ||
]); | ||
var files = ['list/one', 'list/two'].map(function(file){ | ||
var stats = fs.statSync('./test_files/'+file); | ||
return {Key: file, Size: stats.size, LastModified: stats.mtime}; | ||
}); | ||
page.Contents.should.eql(files); | ||
done(); | ||
@@ -158,5 +160,7 @@ }); | ||
if (err) return done(err); | ||
page.Contents.should.eql([ | ||
{Key: "list/one"}, {Key: "list/two"} | ||
]); | ||
var files = ['list/one', 'list/two'].map(function(file){ | ||
var stats = fs.statSync('./test_files/'+file); | ||
return {Key: file, Size: stats.size, LastModified: stats.mtime}; | ||
}); | ||
page.Contents.should.eql(files); | ||
done(); | ||
@@ -169,5 +173,7 @@ }); | ||
if (err) return done(err); | ||
page.Contents.should.eql([ | ||
{Key: "list_nested/level/one"}, {Key: "list_nested/level/two"} | ||
]); | ||
var files = ['list_nested/level/one', 'list_nested/level/two'].map(function(file){ | ||
var stats = fs.statSync('./test_files/'+file); | ||
return {Key: file, Size: stats.size, LastModified: stats.mtime}; | ||
}); | ||
page.Contents.should.eql(files); | ||
done(); | ||
@@ -174,0 +180,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15935
317