Tone.js/scripts/collect_tests.js

36 lines
792 B
JavaScript
Raw Normal View History

2018-08-23 04:17:35 +00:00
const glob = require("glob");
const fs = require("fs");
const { resolve } = require("path");
const argv = require("yargs")
.alias("i", "file")
.alias("d", "dir")
.argv;
/**
* COLLECT TESTS
*/
function collectTests(){
return new Promise((done, error) => {
2018-08-26 23:46:47 +00:00
var tests = "../test/!(helper|deps|examples|html)/*.js";
2018-08-23 04:17:35 +00:00
if (typeof argv.file === "string"){
tests = `../test/*/${argv.file}.js`;
} else if (typeof argv.dir === "string"){
tests = `../test/${argv.dir}/*.js`;
}
glob(resolve(__dirname, tests), (e, files) => {
if (e){
error(e);
}
var reqString = files.map(r => `require("${r}");`).join("\n");
fs.writeFile(resolve(__dirname, "../test/test.js"), reqString, (e) => {
if (e){
error(e);
}
done();
});
});
});
}
collectTests();