0.2.0 • Published 7 years ago
runnable-exports v0.2.0
runnable-exports
Run your
exportsas command line arguments
If you want to easily create a command line tool from a file and a bunch of exported functions.
Install
$ yarn add runnable-exportsUsage
// your-file.js
const runnableExports = require('runnable-exports')
module.exports.awesome = ...args => {
console.log('Awesome', args)
}
runnableExports()And simply
$ node your-file.js awesome and nice argumentsOutput
Awesome ['and', 'nice', 'arguments']ObjectArgs
// your-file.js
const runnableExports = require('runnable-exports')
module.exports.awesome = args => {
console.log('Awesome', args)
}
runnableExports()Under the hood yargs is used, so you can pass easily also objectArgs like so
$ node your-file.js awesome --niceOutput
Awesome {nice: true}NOTE: the module accepts both types of args, the object args will be the first arg passed to the called function, all other args will follow from this
Test
XO and AVA
$ yarn testRelated
This is a fork of make-runnable
License
MIT © LasaleFamine