Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
replace colors with chalk
Browse files Browse the repository at this point in the history
  • Loading branch information
thebuilder committed Jan 10, 2022
1 parent 1d82205 commit 9659564
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 389 deletions.
12 changes: 6 additions & 6 deletions bin/dato.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env node

const PrettyError = require('pretty-error');
const colors = require('colors');
const chalk = require('chalk');

require('../lib');
const runCli = require('../lib/cli');
const ApiException = require('../lib/ApiException').default;

runCli().catch(e => {
process.stderr.write(colors.brightRed(`\nCommand failed!\n`));
process.stderr.write(chalk.brightRed(`\nCommand failed!\n`));

if (e instanceof ApiException) {
const humanMessage = e.humanMessageForFailedResponse();

if (humanMessage) {
process.stderr.write(`${colors.red.underline(humanMessage)} \n\n`);
process.stderr.write(`${chalk.red.underline(humanMessage)} \n\n`);
}

process.stderr.write(colors.underline.gray(`\nFailed request:\n\n`));
process.stderr.write(chalk.underline.gray(`\nFailed request:\n\n`));

process.stderr.write(`${e.requestMethod} ${e.requestUrl}\n\n`);
for (const [key, value] of Object.entries(e.requestHeaders)) {
Expand All @@ -27,7 +27,7 @@ runCli().catch(e => {
process.stderr.write(`\n${e.requestBody}`);
}

process.stderr.write(colors.underline.gray(`\n\nHTTP Response:\n\n`));
process.stderr.write(chalk.underline.gray(`\n\nHTTP Response:\n\n`));

process.stderr.write(`${e.statusCode} ${e.statusText}\n\n`);
for (const [key, value] of Object.entries(e.headers)) {
Expand All @@ -39,7 +39,7 @@ runCli().catch(e => {
}
}

process.stderr.write(colors.underline.gray(`\n\nException details:\n\n`));
process.stderr.write(chalk.underline.gray(`\n\nException details:\n\n`));
process.stderr.write(new PrettyError().render(e));
process.exit(1);
});
Loading

0 comments on commit 9659564

Please sign in to comment.