Skip to content

Commit

Permalink
feat(cqmd): run on first pass, catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jashmenn committed Jan 24, 2019
1 parent 663c5a2 commit 024ae33
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/cqmd/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 024ae33

Please sign in to comment.