otu

One-file npm-package Javascripts. Inspired by php-melody — 'One-file composer scripts'.


Keywords
melody-php, npm-package, es6, espree, cli, one-file, javascript, package-json
License
MIT
Install
npm install otu@1.1.0-beta

Documentation

Build status — Travis-CI js-semistandard-style onefile on Npmjs License

nfreear / otu-js

One-file npm-package Javascripts.

"otu" === "one" (Igbo)

Inspired by php-melody — 'One-file composer scripts'."

The dependencies that you'd normally define in a separate package.json file, are placed at the top of the Javascript in a multi-line ES6 template string, in YAML format, using the constant name _PKG_:

const _PKG_ = `
dependencies:
  package-A: ^1.2
  package-B: ^2.3
`;


// Rest of the Javascript ...

Here is a trivial 'hello world' example, with a single dependency, shelljs:

// eslint-disable-next-line
const _PKG_ = `
dependencies:
  shelljs: ^0.7.8
`;

const shell = require('shelljs');

shell.echo('Hello world!');

The above file can be executed like so (npm install & node script.js are run internally):

npm install otu -g

otu run examples/shelljs-ex.js

Note, the file is valid Javascript (ES6):

node -c examples/shelljs-ex.js

Install ... test

npm install
npm test

License

License: MIT.

Twitter: @nfreear.