https://github.com/lasalefamine/runnable-exports
Run your exports as command line arguments
https://github.com/lasalefamine/runnable-exports
exports module runnable runnable-exports
Last synced: about 2 months ago
JSON representation
Run your exports as command line arguments
- Host: GitHub
- URL: https://github.com/lasalefamine/runnable-exports
- Owner: LasaleFamine
- License: mit
- Created: 2017-01-23T21:56:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-13T18:51:45.000Z (almost 8 years ago)
- Last Synced: 2025-02-28T19:47:10.057Z (over 1 year ago)
- Topics: exports, module, runnable, runnable-exports
- Language: JavaScript
- Homepage:
- Size: 250 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# runnable-exports
[](https://travis-ci.com/emurphy-9/runnable-exports) [](https://coveralls.io/github/emurphy-9/runnable-exports?branch=master)
> Run your `exports` as 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-exports
## Usage
```javascript
// 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 arguments
Output
Awesome ['and', 'nice', 'arguments']
### ***ObjectArgs***
```javascript
// your-file.js
const runnableExports = require('runnable-exports')
module.exports.awesome = args => {
console.log('Awesome', args)
}
runnableExports()
```
Under the hood [yargs](https://www.npmjs.com/package/yargs) is used, so you can pass easily also `objectArgs` like so
$ node your-file.js awesome --nice
Output
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 test
## Related
This is a fork of [make-runnable](https://github.com/super-cache-money/make-runnable)
## License
MIT © LasaleFamine