@jbangdev/jbang

0.2.0 • Public • Published

jbang-npm - Java Script in your JavaScript

Install and use JBang from npm based projects.

Lets you use your own local scripts, JBang AppStore alias or any network reachable jar or Maven artifact.

Usage

The jbang.exec() function accepts a string that will be passed as the command-line arguments to the jbang executable.

Given this script test.js:

#! /usr/bin/env node
const jbang = require('@jbangdev/jbang');
jbang.exec('properties@jbangdev');

And in package.json (use the latest version from npm):

{
  "scripts": {
    "test": "node test.js"
  },
  "devDependencies": {
    "@jbangdev/jbang": "^0.1.4"
  }
}

Now you can invoke the test script from the command-line:

npm run test

You can easily pass command-line arguments around:

let args = process.argv.slice(2).join(' ');
jbang.exec('com.myco.mylib:RELEASE ' + args);

So now if you run npm run test arg1 arg2, arg1 arg2 will be appended to the command executed.

Behind the scenes

When you run npm install - JBang and other dependencies will be installed via the npm preinstall hook. This uses the app setup command.

Opening a new terminal or shell may be required to be able to use the jbang command from the system PATH.

Using as a dependency

In most cases you should be able to use JBang directly in node scripts.

But if you want to provide more customization you can create your own "wrapper" NPM package. One of the advantages is that you can pre-install the library dependencies needed at the time of npm install (just by calling --help or a similar "no op" command) so that the user-experience when running the first command after install is better.

For an example, refer to the @karatelabs/karate NPM package.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    596
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    596
  • 0.1.4
    736
  • 0.1.2
    1
  • 0.1.1
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i @jbangdev/jbang

Homepage

jbang.dev

Weekly Downloads

1,335

Version

0.2.0

License

MIT

Unpacked Size

4.46 kB

Total Files

5

Last publish

Collaborators

  • maxandersen