mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
36 lines
787 B
JavaScript
36 lines
787 B
JavaScript
|
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) => {
|
||
|
var tests = "../test/!(helper|deps|examples)/*.js";
|
||
|
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();
|