From 024ae332cd788774bc3e864ec2ef25134e2454e8 Mon Sep 17 00:00:00 2001 From: Nate Murray Date: Thu, 24 Jan 2019 09:59:19 -0600 Subject: [PATCH] feat(cqmd): run on first pass, catch errors --- packages/cqmd/src/cli.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/cqmd/src/cli.js b/packages/cqmd/src/cli.js index 27f501a..25ce1ea 100755 --- a/packages/cqmd/src/cli.js +++ b/packages/cqmd/src/cli.js @@ -67,7 +67,11 @@ let argv = yargs let [filename] = argv._; argv.absoluteFilePath = filename ? path.resolve(filename) : null; -argv.path = argv.path || path.dirname(argv.absoluteFilePath); +argv.path = argv.path + ? argv.path + : argv.absoluteFilePath + ? path.dirname(argv.absoluteFilePath) + : null; argv.output = argv.output ? path.resolve(argv.output) : null; const outputIsDir = argv.output && fs.lstatSync(argv.output).isDirectory(); @@ -133,7 +137,20 @@ if (argv.watch || argv.watchGlob) { watcher.on("change", async changedPath => { console.log(`File ${changedPath} changed`); - await processCqFile(changedPath, cqOptions); + try { + await processCqFile(changedPath, cqOptions); + } catch (err) { + console.log("ERROR:", changedPath, err); + } + }); + + watcher.on("add", async changedPath => { + console.log(`File ${changedPath} detected`); + try { + await processCqFile(changedPath, cqOptions); + } catch (err) { + console.log("ERROR:", changedPath, err); + } }); if (filename) {