eshost-cli
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -19,3 +19,3 @@ #!/usr/bin/env node | ||
eshost --list | ||
eshost --add [host name] [host type] <host path> <host arguments> | ||
eshost --add [host name] [host type] <host path> --args <host arguments> | ||
eshost --delete [host name] | ||
@@ -27,5 +27,7 @@ `.trim(); | ||
.usage(usage) | ||
.describe('e', 'eval a string') | ||
.describe('e', 'eval an expression and print the result') | ||
.alias('e', 'eval') | ||
.describe('h', 'select hosts by name') | ||
.describe('x', 'execute a multi-statement program') | ||
.alias('x', 'execute') | ||
.describe('h', 'select hosts by name (glob syntax is supported as well)') | ||
.alias('h', 'host') | ||
@@ -56,3 +58,3 @@ .describe('g', 'select host groups by host type') | ||
.nargs('delete', 1) | ||
.describe('args', 'set arguments for a host entry') | ||
.describe('args', 'set arguments for a host entry (use with --add)') | ||
.nargs('args', 1) | ||
@@ -64,2 +66,3 @@ .help('help') | ||
.example('eshost -e "1+1"') | ||
.example('eshost -its -x "for (let i=0; i<10; ++i) { print(i) }"') | ||
.example('eshost -h d8 -h chakra test.js') | ||
@@ -69,2 +72,4 @@ .example('eshost -h d8,sm test.js') | ||
.example('eshost -h d8 -g node test.js') | ||
.example('eshost -h ch-*,node test.js') | ||
.example('eshost -h ch-1.?.? test.js') | ||
.fail(function (msg, err) { | ||
@@ -95,2 +100,23 @@ if (err) { | ||
// Add host glob matches to hosts | ||
let newHosts = []; | ||
for (let host of hosts) { | ||
if (host.indexOf('*') >= 0 || host.indexOf('?') >= 0) { | ||
let re = '^' + host | ||
.replace(/\./g, '\\.') // escape . with /\./ | ||
.replace(/\*/g, '.*') // change * to /.*/ for matches | ||
.replace(/\?/g, '.') // change ? to /./ for matches | ||
+ '$'; | ||
let matcher = new RegExp(re); | ||
for (let hostName of Object.keys(config.hosts)) { | ||
if (matcher.test(hostName)) { | ||
newHosts.push(hostName); | ||
} | ||
} | ||
} else { | ||
newHosts.push(host); | ||
} | ||
hosts = newHosts; | ||
} | ||
let hostGroups; | ||
@@ -160,3 +186,2 @@ if (Array.isArray(argv.g)) { | ||
const file = argv._[0]; | ||
const evalString = argv.e; | ||
@@ -170,2 +195,4 @@ process.stdin.setEncoding('utf8'); | ||
runInEachHost(`print(${argv.e})`, hosts); | ||
} else if (argv.x) { | ||
runInEachHost(argv.x, hosts); | ||
} else { | ||
@@ -172,0 +199,0 @@ let script = ''; |
@@ -35,3 +35,3 @@ 'use strict'; | ||
chalk.red( | ||
`Host '${type}' not supported. Supported hosts are: ${esh.supportedHosts.join(', ')}` | ||
`Host type '${type}' not supported. Supported host types are: ${esh.supportedHosts.join(', ')}` | ||
) | ||
@@ -38,0 +38,0 @@ ); |
@@ -0,0 +0,0 @@ module.exports = class Reporter { |
@@ -0,0 +0,0 @@ const Reporter = require('../Reporter.js'); |
@@ -0,0 +0,0 @@ const Reporter = require('../Reporter.js'); |
{ | ||
"name": "eshost-cli", | ||
"version": "3.2.0", | ||
"version": "3.3.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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
385
13364
10
1