From d85dd8f45ad0032741eb07e650e82243205c02bc Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Sun, 23 Aug 2020 21:47:19 -0400 Subject: [PATCH] deploy: factor out runAq, print warning on success w/o -o/-v --- tools/deploy/index.ts | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/tools/deploy/index.ts b/tools/deploy/index.ts index 869faa61..f3097687 100644 --- a/tools/deploy/index.ts +++ b/tools/deploy/index.ts @@ -7,6 +7,23 @@ function collect(value : string, previous : string[]) { return previous.concat([value]); } +function runAq(aq : script.ActionQueue, outputDir : undefined | string, verbose : undefined | true) { + const level = verbose ? 'all' : 'errors'; + if (!aq.valid) { + aq.print(level); + process.exit(1); + } + if (outputDir !== undefined) { + aq.run(outputDir, 'copy'); + } else { + if (level === 'errors') { + console.log(`Success, but nothing to do. Please rerun with -v or -o`); + } else { + aq.print('all'); + } + } +} + program .command('copy [files...]') .option('-o, --output ', 'Output directory') @@ -39,17 +56,7 @@ program } } - const level = verbose ? 'all' : 'errors'; - - if (outputDir) { - if (!aq.valid) { - aq.print(level); - process.exit(1); - } - aq.run(outputDir, 'copy'); - } else { - aq.print(level); - } + runAq(aq, outputDir, verbose); }); program @@ -68,18 +75,8 @@ program aq.throw(e); } } - - const level = verbose ? 'all' : 'errors'; - - if (outputDir) { - if (!aq.valid) { - aq.print(level); - process.exit(1); - } - aq.run(outputDir, 'link'); - } else { - aq.print(level); - } + + runAq(aq, outputDir, verbose); }); program.parse(process.argv);