Skip to content

Commit

Permalink
πŸ“¦ NEW: Log symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Mar 20, 2020
1 parent 0107c74 commit ff557b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Node Cli Handle Error.
*/
const ora = require('ora');
const sym = require('log-symbols');
const chalk = require('chalk');
const red = chalk.bold.red;
const yellow = chalk.bold.yellow;
const spinner = ora({ text: '' });

/**
* @param {String} heading
Expand All @@ -17,12 +16,12 @@ module.exports = (heading = `ERROR: `, err, displayError = true, exit = true) =>
if (err) {
console.log();
if (displayError) {
spinner.fail(`${red(heading)}`);
spinner.fail(`${red(`ERROR β†’`)} ${err.name}`);
spinner.fail(`${red(`REASON β†’`)} ${err.message}`);
spinner.fail(`${red(`ERROR STACK ↓ \n`)} ${err.stack}\n`);
console.log(`${sym.fail} ${red(heading)}`);
console.log(`${sym.fail} ${red(`ERROR β†’`)} ${err.name}`);
console.log(`${sym.info} ${red(`REASON β†’`)} ${err.message}`);
console.log(`${sym.info} ${red(`ERROR STACK ↓ \n`)} ${err.stack}\n`);
} else {
spinner.warn(`${yellow(heading)}`);
console.log(`${sym.warn} ${yellow(heading)}`);
}
if (exit) {
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
},
"dependencies": {
"chalk": "^3.0.0",
"ora": "^4.0.3"
"log-symbols": "^3.0.0"
}
}

0 comments on commit ff557b5

Please sign in to comment.