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 {
|
2021-07-11 15:25:22 +03:00
|
|
|
test?: string;
|
2019-04-13 09:17:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
2021-07-11 15:25:22 +03:00
|
|
|
if (json.test) {
|
|
|
|
if (!result[json.test]) {
|
|
|
|
result[json.test] = [];
|
|
|
|
}
|
2019-04-13 09:17:23 +03:00
|
|
|
|
2021-07-11 15:25:22 +03:00
|
|
|
result[json.test].push(json);
|
|
|
|
delete json.test;
|
|
|
|
}
|
2019-04-13 09:17:23 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
const output = resolve(__dirname, '../', process.argv[3]);
|
|
|
|
writeFileSync(output, JSON.stringify(result));
|
|
|
|
|
|
|
|
console.log(`Wrote file ${output}`);
|