Super simple task runner to call named functions from CLI
$ npm install pon --save
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()
- 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()
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:*"
Use pon-scaffold to generate your own plugin.
npm i pon-scaffold -g
Pass the task name to generate
pon-scaffold task "pon-task-my-own"
Then, edit lib/define.js under the generated project.
This software is released under the Apache-2.0 License.