Package Exports
- ok-runner
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ok-runner) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
👌 ok-runner 👌
Table of Contents
Motivation
I usually use npm scripts extensively as a build tool when building libraries. Though this leads to my package.json becoming bloated and does not allow for proper commenting of longer commands. I wanted a simple build tool that allowed me to execute commands and functions(in more complex cases) with minimal effort. The popular solutions felt like overkill so I made my own. It ain't the next big thing, but it works fine.
Install
$ npm install --save ok-runner
# Or
$ yarn add ok-runnerUsage
Create a js file in your project directory. for example ok.js
In ok.js:
const ok = require('ok-runner')
ok
.run('Greet', 'echo Hello!')
.run('Do some logging', () => {
console.log('log')
console.log('All')
console.log('The')
console.log('Things!')
})
.run('Touch a file', 'touch aFile')
.run('Remove a file', 'rm aFile')
You can then run the file in your terminal:
$ node ok.jsIf the second argument is a string, it will be wrapped in a the ok.exec property that supports executing locally installed binaries by name.
Or you can run specific commands by using the cli. Modify your ok.js:
const ok = require('ok-runner')
ok
.task('Greet', 'echo Hello!')
.task('Do some logging', () => {
console.log('log')
console.log('All')
console.log('The')
console.log('Things!')
})
.task('Touch a file', 'touch aFile')
.task('Remove a file', 'rm aFile')
module.exports.ok
Then, after installing globally or via your npm scripts:
$ ok GreetThis will execute only the hello task. only running ok will run all the tasks
The cli looks for a file named ok.js otherwise you must specify the script name:
ok --script=example.jsAPI
The module exports a singleton ok object with the following methods:
ok.run(taskName: String, handler: String|Function)
Runs a task with the given taskName by executing the given string command or function. If no handler is provided, the created tasks are checked for a matching task and executed
ok.task(taskName: String, handler: String|Function)
Creates a new task with name taskName that can be ran using the ok.run method or via the cli.
ok.args
An object containing all the argument options parsed using get-them-args
ok.exec(command, options, cb)
A simple wrapper around shelljs's exec method after extending it support executing locally installed binaries by name.
Example
Please check the example directory.
Contribute
Contributions are welcome. Please open up an issue or create PR if you would like to help out.
Note: If editing the README, please conform to the standard-readme specification.
License
Licensed under the MIT License.