ava-fixture
Advanced tools
@@ -5,4 +5,15 @@ import { fixture as f } from './fixture'; | ||
export declare function fixture(dir: any): { | ||
eachFile(cb: any): void; | ||
eachDirectory(cb: any): void; | ||
directory(name: any, cb: (d: { | ||
name: string; | ||
path: string; | ||
}) => any): void; | ||
eachFile(cb: (d: { | ||
name: string; | ||
path: string; | ||
filename: string; | ||
}) => any): void; | ||
eachDirectory(cb: (d: { | ||
name: string; | ||
path: string; | ||
}) => any): void; | ||
}; |
@@ -10,10 +10,15 @@ import { fixture as f } from './fixture'; | ||
cache[absDir] = {}; | ||
const files = readdirSync(absDir); | ||
files.forEach(file => { | ||
const stat = statSync(join(absDir, file)); | ||
const id = stat.isDirectory() ? 'd' : 'f'; | ||
const entries = readdirSync(absDir); | ||
entries.forEach(entry => { | ||
const id = isDirectory(absDir, entry) ? 'd' : 'f'; | ||
const node = cache[absDir][id] || (cache[absDir][id] = []); | ||
node.push(file); | ||
node.push(entry); | ||
}); | ||
return { | ||
directory(name, cb) { | ||
cb({ | ||
name, | ||
path: resolve(absDir, name) | ||
}); | ||
}, | ||
eachFile(cb) { | ||
@@ -38,2 +43,6 @@ cache[absDir].f.forEach(filename => { | ||
} | ||
function isDirectory(path, name) { | ||
const stat = statSync(join(path, name)); | ||
return stat.isDirectory(); | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -5,4 +5,15 @@ import { fixture as f } from './fixture'; | ||
export declare function fixture(dir: any): { | ||
eachFile(cb: any): void; | ||
eachDirectory(cb: any): void; | ||
directory(name: any, cb: (d: { | ||
name: string; | ||
path: string; | ||
}) => any): void; | ||
eachFile(cb: (d: { | ||
name: string; | ||
path: string; | ||
filename: string; | ||
}) => any): void; | ||
eachDirectory(cb: (d: { | ||
name: string; | ||
path: string; | ||
}) => any): void; | ||
}; |
@@ -15,10 +15,15 @@ "use strict"; | ||
cache[absDir] = {}; | ||
var files = fs_1.readdirSync(absDir); | ||
files.forEach(function (file) { | ||
var stat = fs_1.statSync(path_1.join(absDir, file)); | ||
var id = stat.isDirectory() ? 'd' : 'f'; | ||
var entries = fs_1.readdirSync(absDir); | ||
entries.forEach(function (entry) { | ||
var id = isDirectory(absDir, entry) ? 'd' : 'f'; | ||
var node = cache[absDir][id] || (cache[absDir][id] = []); | ||
node.push(file); | ||
node.push(entry); | ||
}); | ||
return { | ||
directory: function (name, cb) { | ||
cb({ | ||
name: name, | ||
path: path_1.resolve(absDir, name) | ||
}); | ||
}, | ||
eachFile: function (cb) { | ||
@@ -44,2 +49,6 @@ cache[absDir].f.forEach(function (filename) { | ||
exports.fixture = fixture; | ||
function isDirectory(path, name) { | ||
var stat = fs_1.statSync(path_1.join(path, name)); | ||
return stat.isDirectory(); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ava-fixture", | ||
"description": "Write fixture tests with ava", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"main": "dist/es5/index.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/es2015/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
108155
1.96%27
42.11%919
4.55%