Skip to content

Commit

Permalink
Merge pull request #1396 from mccraveiro/cli-error
Browse files Browse the repository at this point in the history
Pretty print ENOENT errors on cli
  • Loading branch information
styfle authored Dec 20, 2018
2 parents fe91a61 + 327c9d8 commit 0fd0a97
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/marked
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,22 @@ function camelize(text) {
});
}

function handleError(err) {
if (err.code === 'ENOENT') {
console.error(`marked: output to ${err.path}: No such directory`);
return process.exit(1);
}
throw err;
}

/**
* Expose / Entry Point
*/

if (!module.parent) {
process.title = 'marked';
main(process.argv.slice(), function(err, code) {
if (err) throw err;
if (err) return handleError(err);
return process.exit(code || 0);
});
} else {
Expand Down

0 comments on commit 0fd0a97

Please sign in to comment.