refactor config filename and convert to yaml

This commit is contained in:
William Welling
2021-12-08 09:38:52 -06:00
parent bc999d0b5f
commit 10622008c4
16 changed files with 330 additions and 45 deletions

32
scripts/env-to-yaml.ts Normal file
View File

@@ -0,0 +1,32 @@
import * as fs from 'fs';
import * as yaml from 'js-yaml';
import { join } from 'path';
const args = process.argv.slice(2);
if (args[0] === undefined) {
console.log(`Usage:\n\tyarn env:yaml [relative path to environment.ts file] (optional relative path to write yaml file)\n`);
process.exit(0);
}
const envFullPath = join(process.cwd(), args[0]);
if (!fs.existsSync(envFullPath)) {
console.error(`Error:\n${envFullPath} does not exist\n`);
process.exit(1);
}
try {
const env = require(envFullPath);
const config = yaml.dump(env);
if (args[1]) {
const ymlFullPath = join(process.cwd(), args[1]);
fs.writeFileSync(ymlFullPath, config);
} else {
console.log(config);
}
} catch (e) {
console.error(e);
}