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-lineconst _PKG_ = `dependencies: shelljs: ^0.7.8`; const shell = ; shell;
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 installnpm test
License
License: MIT.
Twitter: @nfreear.