Organize tasks with namespaces
mainUse namespace to group tasks and prevent name collisions. Tasks inside a namespace are accessed via namespace:taskname. Namespaces support lifecycle hooks: before(), after(), and onerror().
Nesting: Namespaces can be nested, resulting in colon-separated names like parent:child:task.
import { task, namespace, logger } from 'foy'
namespace('client', ns => {
before(() => logger.info('before'))
after(() => logger.info('after'))
onerror(() => logger.info('onerror'))
task('start', async ctx => { /* ... */ }) // accessed as client:start
namespace('proj1', ns => {
task('start', async ctx => { /* ... */ }) // accessed as client:proj1:start
})
})
namespace('server', ns => {
task('start', async ctx => { /* ... */ }) // accessed as server:start
})