Skip to content

trashify/ok-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‘Œ ok-runner πŸ‘Œ

A task runner that works just fine



Built with ❀︎ by Tiaan and contributors

Table of Contents

Table of Contents
  • Install
  • Usage
  • API
  • Contribute
  • License
  • Install

    $ npm install --save ok-runner
    # Or
    $ yarn add ok-runner

    Usage

    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

    API

    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.

    Releases

    No releases published

    Packages

    No packages published