1.1.0-beta • Published 8 years ago
otu v1.1.0-beta
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.jsNote, the file is valid Javascript (ES6):
node -c examples/shelljs-ex.jsInstall ... test
npm install
npm testLicense
License: MIT.
Twitter: @nfreear.
1.1.0-beta
8 years ago