sprites/tools/deploy/index.ts
Christopher Monsanto b11b520a38 deploy: TS index
2020-08-07 04:34:09 -04:00

38 lines
994 B
TypeScript

import program from 'commander';
import {run} from './lang.js';
import {find} from './find.js';
import {link} from './deploy.js';
program
.command('deploy <tag> <outputDir>')
.option('-d, --dir [dir]', 'Directory')
.action((tag : string, outputDir : string, opts) => {
const dir = opts.dir || '.';
const results = run(find(dir, tag));
link(results, outputDir);
});
program
.command('print <tag>')
.option('-d, --dir [dir]', 'Directory')
.option('--json', 'As JSON')
.action((tag : string, opts) => {
const dir = opts.dir || '.';
const results = run(find(dir, tag));
if (opts.json) {
process.stdout.write(JSON.stringify(results, null, ' ') + "\n");
} else {
for (const {src, dst} of results) {
console.log(`${src} ==> ${dst}`);
}
}
});
program.parse(process.argv);
if (process.argv.slice(2).length === 0) {
program.outputHelp();
}