Comparing version 0.2.3 to 0.2.4
#!/usr/bin/env node | ||
var rimraf = require('rimraf') | ||
var fs = require('fs') | ||
var childProcess = require('child_process') | ||
var walkSync = require('./') | ||
'use strict'; | ||
rimraf.sync('benchmark.tmp') | ||
var rimraf = require('rimraf'); | ||
var fs = require('fs'); | ||
var childProcess = require('child_process'); | ||
var walkSync = require('./'); | ||
var directories = 100, files = 1000 | ||
rimraf.sync('benchmark.tmp'); | ||
var directories = 100, files = 1000; | ||
function createDirWithFiles(dir) { | ||
fs.mkdirSync(dir) | ||
fs.mkdirSync(dir); | ||
for (var i = 0; i < files; i++) { | ||
fs.writeFileSync(dir + '/' + i, 'foo') | ||
fs.writeFileSync(dir + '/' + i, 'foo'); | ||
} | ||
} | ||
console.log('Creating ' + (directories * files) + ' files across ' + directories + ' directories') | ||
createDirWithFiles('benchmark.tmp') | ||
console.log('Creating ' + (directories * files) + ' files across ' + directories + ' directories'); | ||
createDirWithFiles('benchmark.tmp'); | ||
for (var i = 0; i < directories - 1; i++) { | ||
createDirWithFiles('benchmark.tmp/dir' + i) | ||
createDirWithFiles('benchmark.tmp/dir' + i); | ||
} | ||
childProcess.spawnSync('sync') | ||
childProcess.spawnSync('sync'); | ||
console.time('walkSync') | ||
console.time('walkSync'); | ||
for (i = 0; i < 5; i++) { | ||
walkSync('benchmark.tmp') | ||
walkSync('benchmark.tmp'); | ||
} | ||
console.timeEnd('walkSync') | ||
console.timeEnd('walkSync'); | ||
console.time('walkSync with **/* glob') | ||
console.time('walkSync with **/* glob'); | ||
for (i = 0; i < 5; i++) { | ||
walkSync('benchmark.tmp', ['**/*']) | ||
walkSync('benchmark.tmp', ['**/*']); | ||
} | ||
console.timeEnd('walkSync with **/* glob') | ||
console.timeEnd('walkSync with **/* glob'); | ||
console.time('walkSync with **/*DOESNOTMATCH glob') | ||
console.time('walkSync with **/*DOESNOTMATCH glob'); | ||
for (i = 0; i < 5; i++) { | ||
walkSync('benchmark.tmp', ['**/*DOESNOTMATCH']) | ||
walkSync('benchmark.tmp', ['**/*DOESNOTMATCH']); | ||
} | ||
console.timeEnd('walkSync with **/*DOESNOTMATCH glob') | ||
console.timeEnd('walkSync with **/*DOESNOTMATCH glob'); | ||
console.time('walkSync with DOESNOTMATCH*/** glob') | ||
console.time('walkSync with DOESNOTMATCH*/** glob'); | ||
for (i = 0; i < 5; i++) { | ||
walkSync('benchmark.tmp', ['DOESNOTMATCH*/**']) | ||
walkSync('benchmark.tmp', ['DOESNOTMATCH*/**']); | ||
} | ||
console.timeEnd('walkSync with DOESNOTMATCH*/** glob') | ||
console.timeEnd('walkSync with DOESNOTMATCH*/** glob'); | ||
rimraf.sync('benchmark.tmp') | ||
rimraf.sync('benchmark.tmp'); |
# master | ||
# 0.2.4 | ||
* Fix file entries to have a numeric timestamp rather than a `Date` | ||
# 0.2.3 | ||
@@ -4,0 +8,0 @@ |
@@ -38,3 +38,3 @@ 'use strict'; | ||
return _walkSync(baseDir, options); | ||
} | ||
}; | ||
@@ -70,3 +70,3 @@ function _walkSync(baseDir, options, _relativePath) { | ||
if (!m || m.match(entryRelativePath)) { | ||
results.push(new Entry(entryRelativePath, baseDir, stats && stats.mode, stats && stats.size, stats && stats.mtime)); | ||
results.push(new Entry(entryRelativePath, baseDir, stats && stats.mode, stats && stats.size, stats && stats.mtime.getTime())); | ||
} | ||
@@ -73,0 +73,0 @@ } |
{ | ||
"name": "walk-sync", | ||
"description": "Get an array of recursive directory contents", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"author": "Jo Liss <joliss42@gmail.com>", | ||
@@ -16,2 +16,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"jshint-tap-simple": "^1.0.2", | ||
"rimraf": "^2.4.3", | ||
@@ -18,0 +19,0 @@ "tap": "^1.0.0" |
@@ -1,6 +0,7 @@ | ||
var fs = require('fs') | ||
var tap = require('tap') | ||
var test = tap.test | ||
var walkSync = require('../') | ||
'use strict'; | ||
var tap = require('tap'); | ||
var test = tap.test; | ||
var walkSync = require('../'); | ||
function captureError(fn) { | ||
@@ -15,8 +16,8 @@ try { | ||
tap.Test.prototype.addAssert('matchThrows', 2, function(fn, expectedError) { | ||
var error = captureError(fn) | ||
var error = captureError(fn); | ||
this.type(error, Error); | ||
this.equal(error.name, expectedError.name) | ||
this.match(error.message, expectedError.message) | ||
}) | ||
this.equal(error.name, expectedError.name); | ||
this.match(error.message, expectedError.message); | ||
}); | ||
@@ -35,30 +36,22 @@ test('walkSync', function (t) { | ||
'symlink1/qux.txt', | ||
'symlink2', | ||
]) | ||
'symlink2' | ||
]); | ||
t.matchThrows(function() { | ||
walkSync('test/doesnotexist') | ||
walkSync('test/doesnotexist'); | ||
}, { | ||
name: 'Error', | ||
message: /ENOENT.* 'test\/doesnotexist/ | ||
}) | ||
}); | ||
t.matchThrows(function() { | ||
walkSync('test/fixtures/foo.txt') | ||
walkSync('test/fixtures/foo.txt'); | ||
}, { | ||
name: 'Error', | ||
message: /ENOTDIR.* 'test\/fixtures\/foo.txt/ | ||
}) | ||
}); | ||
t.end() | ||
t.end(); | ||
}); | ||
function byFile(obj) { | ||
return obj.file; | ||
} | ||
function byStat(obj) { | ||
return obj.stat; | ||
} | ||
function appearsAsDir(entry) { | ||
@@ -84,2 +77,6 @@ return entry.relativePath.charAt(entry.relativePath.length - 1) === '/'; | ||
t.assert(entry.size > -1); | ||
t.equal(typeof entry.mtime, 'number'); | ||
t.equal(typeof entry.size, 'number'); | ||
t.equal(typeof entry.mode, 'number'); | ||
} | ||
@@ -96,6 +93,6 @@ | ||
test('walkSync \w matchers', function (t) { | ||
test('walkSync with matchers', function (t) { | ||
t.deepEqual(walkSync('test/fixtures', ['dir/bar.txt']), [ | ||
'dir/bar.txt' | ||
]) | ||
]); | ||
@@ -109,3 +106,3 @@ t.deepEqual(walkSync('test/fixtures', { globs: ['dir/bar.txt'] }), [ | ||
'dir/zzz.txt' | ||
]) | ||
]); | ||
@@ -115,3 +112,3 @@ t.deepEqual(walkSync('test/fixtures', ['dir/{bar,zzz}.txt']), [ | ||
'dir/zzz.txt' | ||
]) | ||
]); | ||
@@ -124,3 +121,3 @@ t.deepEqual(walkSync('test/fixtures', ['dir/**/*', 'some-other-dir/**/*']), [ | ||
'some-other-dir/qux.txt' | ||
]) | ||
]); | ||
@@ -135,3 +132,3 @@ t.deepEqual(walkSync('test/fixtures', { | ||
'some-other-dir/qux.txt' | ||
]) | ||
]); | ||
@@ -144,4 +141,4 @@ t.deepEqual(walkSync('test/fixtures', ['**/*.txt']), [ | ||
'some-other-dir/qux.txt', | ||
'symlink1/qux.txt', | ||
]) | ||
'symlink1/qux.txt' | ||
]); | ||
@@ -152,6 +149,6 @@ t.deepEqual(walkSync('test/fixtures', ['{dir,symlink1}/**/*.txt']), [ | ||
'dir/zzz.txt', | ||
'symlink1/qux.txt', | ||
]) | ||
'symlink1/qux.txt' | ||
]); | ||
t.end() | ||
}) | ||
t.end(); | ||
}); |
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
12849
16
253
2
3