mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 12:54:38 +00:00
overhaul tests
This commit is contained in:
23
test/utils.ts
Normal file
23
test/utils.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
export function wait(ms: number) {
|
||||
return new Promise(fulfil => setTimeout(fulfil, ms));
|
||||
}
|
||||
|
||||
export function walk(cwd: string, dir = cwd, files: string[] = []) {
|
||||
fs.readdirSync(dir).forEach(file => {
|
||||
const resolved = path.resolve(dir, file);
|
||||
if (fs.statSync(resolved).isDirectory()) {
|
||||
walk(cwd, resolved, files);
|
||||
} else {
|
||||
files.push(posixify(path.relative(cwd, resolved)));
|
||||
}
|
||||
});
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
function posixify(str: string) {
|
||||
return str.replace(/\\/g, '/');
|
||||
}
|
||||
Reference in New Issue
Block a user