Skip to content

Commit

Permalink
Pretty print ENOENT errors on cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mccraveiro committed Dec 20, 2018
1 parent fe91a61 commit 8f532f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/marked
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 8f532f0

Please sign in to comment.