Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.

Commit f1e93b5

Browse files
committed
feat: improve error display
1 parent 467c6e7 commit f1e93b5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

bin/allow-scripts.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
'use strict';
44

5+
const Ansicolors = require('ansicolors');
6+
57
const Allow = require('..');
68

79
const options = {
@@ -10,6 +12,13 @@ const options = {
1012

1113
Allow.run(options).catch((err) => {
1214

13-
console.error(err);
15+
let log = err;
16+
if (err.stack) {
17+
18+
const [message, ...rest] = err.stack.split('\n');
19+
log = `${Ansicolors.red(message)}\n${rest.join('\n')}`;
20+
}
21+
22+
console.error(`\n\n${log}`);
1423
process.exit(1);
1524
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"author": "Dominykas Blyžė <[email protected]>",
1717
"license": "MIT",
1818
"dependencies": {
19+
"ansicolors": "0.3.x",
1920
"libnpm": "2.x.x",
2021
"semver": "5.x.x",
2122
"topo": "3.x.x"

0 commit comments

Comments
 (0)