Skip to content

Commit

Permalink
Refactor the client
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus-and committed Jul 12, 2018
1 parent fbc22ba commit ec1468c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions bin/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const packageInfo = require('../package.json');

function display(object) {
return util.inspect(object, {
'colors': process.stdout.isTTY,
'depth': null
colors: process.stdout.isTTY,
depth: null
});
}

Expand Down Expand Up @@ -57,9 +57,9 @@ function inspect(target, args, options) {
const registeredEvents = {};

const cdpRepl = repl.start({
'prompt': '\x1b[32m>>>\x1b[0m ',
'ignoreUndefined': true,
'writer': display
prompt: '\x1b[32m>>>\x1b[0m ',
ignoreUndefined: true,
writer: display
});

const homePath = process.env.HOME || process.env.USERPROFILE;
Expand Down Expand Up @@ -107,12 +107,13 @@ function inspect(target, args, options) {
} else {
const promise = command(params);
// use a custom inspect to display the outcome
promise.inspect = function () {
this.then((result) => {
promise.inspect = async () => {
try {
const result = await this;
overridePrompt(display(result));
}).catch((err) => {
} catch (err) {
overridePrompt(display(err));
});
}
// temporary placeholder
return '...';
};
Expand Down Expand Up @@ -340,9 +341,9 @@ program.parse(process.argv);

// common options
const options = {
'host': program.host,
'port': program.port,
'secure': program.secure
host: program.host,
port: program.port,
secure: program.secure
};

if (action) {
Expand Down

0 comments on commit ec1468c

Please sign in to comment.