2019-04-13 09:17:23 +03:00
|
|
|
import {readdirSync, readFileSync, writeFileSync} from 'fs';
|
|
|
|
import {resolve} from 'path';
|
|
|
|
|
2019-05-26 01:54:41 +03:00
|
|
|
if (process.argv.length <= 2) {
|
2019-04-13 09:17:23 +03:00
|
|
|
console.log('No metadata path provided');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2019-05-26 01:54:41 +03:00
|
|
|
if (process.argv.length <= 3) {
|
2019-04-13 09:17:23 +03:00
|
|
|
console.log('No output file given');
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const path = resolve(__dirname, '../', process.argv[2]);
|
|
|
|
const files = readdirSync(path);
|
|
|
|
|
2019-05-26 01:54:41 +03:00
|
|
|
interface RefTestMetadata {}
|
2019-04-13 09:17:23 +03:00
|
|
|
|
2019-05-26 01:54:41 +03:00
|
|
|
interface RefTestSingleMetadata extends RefTestMetadata {
|
2019-04-13 09:17:23 +03:00
|
|
|
test: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface RefTestResults {
|
2019-05-26 01:54:41 +03:00
|
|
|
[key: string]: Array<RefTestMetadata>;
|
2019-04-13 09:17:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const result: RefTestResults = files.reduce((result: RefTestResults, file) => {
|
|
|
|
const json: RefTestSingleMetadata = JSON.parse(readFileSync(resolve(__dirname, path, file)).toString());
|
|
|
|
if (!result[json.test]) {
|
|
|
|
result[json.test] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
result[json.test].push(json);
|
|
|
|
delete json.test;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
const output = resolve(__dirname, '../', process.argv[3]);
|
|
|
|
writeFileSync(output, JSON.stringify(result));
|
|
|
|
|
|
|
|
console.log(`Wrote file ${output}`);
|