@jbangdev/jbang
Advanced tools
Comparing version 0.1.4 to 0.2.0
17
jbang.js
@@ -5,2 +5,3 @@ const shell = require('shelljs'); | ||
argLine = args.join(" "); | ||
let cmdResult = null; | ||
if (shell.which('jbang') | ||
@@ -10,10 +11,10 @@ || (process.platform === 'win32' && shell.which('./jbang.cmd')) // windows | ||
console.log('using jbang:', argLine); | ||
shell.exec('jbang ' + argLine); | ||
cmdResult = shell.exec('jbang ' + argLine); | ||
} else if (shell.which('curl') && shell.which('bash')) { | ||
console.log('using curl + bash:', argLine); | ||
shell.exec('curl -Ls https://sh.jbang.dev | bash -s - ' + argLine); | ||
cmdResult = shell.exec('curl -Ls https://sh.jbang.dev | bash -s - ' + argLine); | ||
} else if (shell.which('powershell')) { | ||
console.log('using powershell:', argLine); | ||
shell.exec('echo iex "& { $(iwr -useb https://ps.jbang.dev) } $args" > %TEMP%/jbang.ps1'); | ||
shell.exec('powershell -Command "%TEMP%/jbang.ps1 ' + argLine + '"'); | ||
cmdResult = shell.exec('powershell -Command "%TEMP%/jbang.ps1 ' + argLine + '"'); | ||
} else { | ||
@@ -23,2 +24,12 @@ shell.echo('unable to pre-install jbang:', argLine); | ||
} | ||
if (cmdResult?.code !== 0) { | ||
const err = new Error(`The command failed: 'jbang ${argLine}'. Code: ${cmdResult?.code}`); | ||
err.code = cmdResult?.code; | ||
err.cause = cmdResult.stderr; | ||
throw err; | ||
} | ||
return cmdResult; | ||
}; | ||
@@ -25,0 +36,0 @@ |
{ | ||
"name": "@jbangdev/jbang", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"description": "NPM for JBang - Java Script in your JavaScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://jbang.dev", |
@@ -20,3 +20,3 @@ # jbang-npm - Java Script in your JavaScript | ||
And in `package.json`: | ||
And in `package.json` (use the latest version from [npm](https://www.npmjs.com/package/@jbangdev/jbang)): | ||
@@ -29,3 +29,3 @@ ```json | ||
"devDependencies": { | ||
"@jbangdev/jbang": "^0.1.0" | ||
"@jbangdev/jbang": "^0.1.4" | ||
} | ||
@@ -32,0 +32,0 @@ } |
#! /usr/bin/env node | ||
var jbang = require('./jbang'); | ||
jbang.exec('properties@jbangdev'); | ||
try { | ||
jbang.exec('badinput'); | ||
console.error('jbang error not caught!'); | ||
process.exit(1); | ||
} catch (err) { | ||
console.log('jbang error caught successfully'); | ||
} |
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
4459
45