A simple task pipeline runner with CLI spinners and formatters
npm install @idlesummer/taskerbash
npm install @idlesummer/tasker
`
Quick Start
Here's the simplest example:
`typescript
import { pipe, type Context } from '@idlesummer/tasker'
interface MyContext extends Context {
count?: number
}
const pipeline = pipe([
{
name: 'Initialize',
run: async () => ({ count: 0 }),
},
{
name: 'Process',
run: async (ctx) => ({ count: (ctx.count ?? 0) + 10 }),
onSuccess: (ctx) => Processed (count: ${ctx.count}),
},
])
const result = await pipeline.run({})
console.log(Done in ${result.duration}ms)
`
That's it! You get:
- Spinners while tasks run â¨
- Type-safe context passing between tasks
- Timing info automatically
Why Would I Use This?
Use this if you:
- Want to build a simple CLI tool or build script
- Like seeing spinners while stuff happens
- Need tasks to share data between each other
- Want something lighter than Gulp but more structured than raw scripts
Don't use this if you:
- Need parallel task execution (tasks run sequentially here)
- Want a mature, battle-tested solution (this is a learning project!)
- Need a full-featured task runner (look at Gulp, Grunt, etc.)
Documentation
- API Reference - All the functions and types explained
- Examples - Real code you can copy-paste
- Architecture - How it works under the hood
- Contributing - Want to help? Start here
- Troubleshooting - Common issues and fixes
Example Projects
The examples/ folder has working projects you can run:
- basic-pipeline - Super simple example to get started
- build-tool - More realistic build tool with file operations
- formatters - Shows off all the formatting utilities
Each example is a standalone npm package. To run one:
`bash
Clone and setup
git clone https://github.com/idlesummer/tasker.git
cd tasker
npm install
npm run build
Try an example
cd examples/basic-pipeline
npm install
npm run build
npm start
`
See the examples README for more info.
Quick API Overview
$3
Create a pipeline with tasks:
`typescript
const pipeline = pipe([
{
name: 'Task name',
onSuccess: (ctx, duration) => 'Custom success message',
onError: (error) => 'Custom error message',
run: async (ctx) => {
// Do stuff
return { key: 'value' } // Updates context
},
}
])
const result = await pipeline.run({})
// result.context has your final context
// result.duration is total time in ms
`
$3
Make numbers pretty:
`typescript
import { bytes, duration, fileList } from '@idlesummer/tasker'
console.log(bytes(1234567)) // "1.23 MB"
console.log(duration(12345)) // "12.3s"
console.log(fileList('./dist')) // Formatted file list with sizes
`
Check API.md for the full reference.
A More Real Example
Here's what a build script might look like:
`typescript
import { pipe, fileList, duration } from '@idlesummer/tasker'
import { exec } from 'child_process'
import { promisify } from 'util'
const execAsync = promisify(exec)
const build = pipe([
{
name: 'Clean dist folder',
run: async () => {
await execAsync('rm -rf dist')
}
},
{
name: 'Compile TypeScript',
onSuccess: () => 'TypeScript compiled successfully',
run: async () => {
await execAsync('tsc')
},
},
{
name: 'Show output',
run: async () => {
console.log('\nBuild output:')
console.log(fileList('./dist'))
}
}
])
console.log('đď¸ Building...\n')
const result = await build.run({})
console.log(\nâ
Done in ${duration(result.duration)})
``