$ npm install --save ok-runner
# Or
$ yarn add ok-runner
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.js
If 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 Greet
This 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.js
The module exports a singleton ok
object with the following methods:
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
Creates a new task with name taskName
that can be ran using the ok.run
method or via the cli.
An object containing all the argument options parsed using get-them-args
A simple wrapper around shelljs's exec
method after extending it support executing locally installed binaries by name.
Please check the example directory.
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.
Licensed under the MIT License.