eshost-cli
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -11,2 +11,5 @@ #!/usr/bin/env node | ||
const hostManager = require('../lib/host-manager.js') ; | ||
const Table = require('cli-table'); | ||
const DefaultReporter = require('../lib/reporters/default.js'); | ||
const TableReporter = require('../lib/reporters/table.js'); | ||
@@ -29,4 +32,12 @@ const usage = ` | ||
.alias('c', 'config') | ||
.describe('table', 'output in a table') | ||
.boolean('table') | ||
.alias('table', 't') | ||
.describe('coalesce', 'coalesce like output into a single entry') | ||
.boolean('coalesce') | ||
.describe('showSource', 'show input source') | ||
.boolean('showSource') | ||
.nargs('h', 1) | ||
.boolean('async', 'wait for realm destruction before reporting results') | ||
.describe('async', 'wait for realm destruction before reporting results') | ||
.boolean('async') | ||
.alias('a', 'async') | ||
@@ -74,2 +85,17 @@ .boolean('l', 'list hosts') | ||
let reporterOptions = { | ||
showSource: argv.showSource, | ||
coalesce: argv.coalesce | ||
}; | ||
if (argv.showSource) { | ||
reporterOptions.showSource = true; | ||
} | ||
let reporter; | ||
if (argv.table) { | ||
reporter = new TableReporter(reporterOptions); | ||
} else { | ||
reporter = new DefaultReporter(reporterOptions); | ||
} | ||
// list available hosts | ||
@@ -132,3 +158,3 @@ if (argv.list) { | ||
let runner; | ||
esh.createAgent(host.type, { hostArguments: host.args, hostPath: host.path }) | ||
return esh.createAgent(host.type, { hostArguments: host.args, hostPath: host.path }) | ||
.then(r => { | ||
@@ -139,8 +165,7 @@ runner = r; | ||
.then(function (result) { | ||
printHostResult(host.name, result); | ||
reporter.result(host, result); | ||
return runner.destroy(); | ||
}) | ||
.catch(e => { | ||
console.error(chalk.red('Failure attempting to eval script in agent: ' + e.message)); | ||
console.error(chalk.red('Failure attempting to eval script in agent: ' + e.stack)); | ||
}) | ||
@@ -150,18 +175,11 @@ } | ||
function runInEachHost(code, hosts) { | ||
hosts.forEach(name => { | ||
reporter.start(code); | ||
let promises = hosts.map(name => { | ||
const host = config.hosts[name]; | ||
host.name = name; | ||
runInHost(host, code); | ||
return runInHost(host, code); | ||
}); | ||
} | ||
function printHostResult(name, result) { | ||
console.log(chalk.blue(`#### ${name}`)); | ||
console.log(result.stdout.trim()); | ||
if (result.error) { | ||
console.log(chalk.red(`${result.error.name}: ${result.error.message}`)); | ||
} | ||
console.log(""); | ||
Promise.all(promises).then(() => reporter.end()); | ||
} |
{ | ||
"name": "eshost-cli", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Run scripts in any ECMAScript host", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13248
13
346