Skip to content

Super simple task runner to call named functions from CLI

License

Notifications You must be signed in to change notification settings

realglobe-Inc/pon

Repository files navigation

pon

Build Status Build Status npm Version JS Standard

Super simple task runner to call named functions from CLI

Table of Contents

Installation

$ npm install pon --save

Usage

Create runner with tasks and pass task names to run

'use strict'

const pon = require('pon')

const css = require('pon-task-css')
const browser = require('pon-task-browser')

async function tryExample () {
  const run = pon({
    'ui:css': css('ui/stylesheets', 'public'),
    'ui:browser': browser('shim/entrypoints', 'public')
  })

  // Execute task by names
  await run('ui:css', 'ui:browser')
}

tryExample()

Advanced Usage

Defining task in various ways

  • Task is just an async function
  • Task can be a string which is the name of another task
  • Tasks can be nested
  • Task can be array of function (or string)
'use strict'

const pon = require('pon')

async function tryNested () {
  const run = pon({
    // Just pass a async function to define custom task
    async yell () { /* ... */ },
    // Arrayed functions runs sequentially
    swing: [ async function up () { /* ... */ }, async function down () { /* ... */ } ],
    fitness: {
      async walk () { /* ... */ },
      async run () { /* ... */ },
      // Default call
      default: [ 'fitness/walk', 'fitness/run' ]
    },
    // Call another tasks
    yellAndRun: [ 'yell', 'fitness/run' ]
  })

  await run('yell', 'swing') // Runs tasks sequentially
  await run('fitness/*') // By pattern
  await run('fitness') // Same as call `await run('fitness.default')
  await run('yellAndRun') // Call another tasks
}

tryNested()

CLI Usage

Install pon-cli as global module.

$ npm install pon-cli -g

Create Ponfile.js at your project root and define tasks there.

'use strict'

const pon = require('pon')

module.exports = pon({
  'myapp:do-something': async function doSomething () {
    /* ... */
  }
})

Then, call task from command line

pon "myapp:*"

Develop Own Plugin

Use pon-scaffold to generate your own plugin.

Install scaffold CLI

npm i pon-scaffold -g

Task Plugin

Pass the task name to generate

pon-scaffold task "pon-task-my-own"

Then, edit lib/define.js under the generated project.

License

This software is released under the Apache-2.0 License.

Links

About

Super simple task runner to call named functions from CLI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published