Yet another task runner.
There is a very good article on the Deno blog with the title You Don't Need a Build Step. Yes, you don't need this task runner either, but it works (maybe) and it was fun to implement it.
deno install --allow-run -RWE -g -n tano jsr:@dx/tano/cliNote:
Your tasks may need additional permissions.
Upgrades the dx cli.
tano --upgradeEvery release is documented in the changelog, including what breaks.
0.6.0 fixed a number of defects, and four of those change what an unchanged tanofile does. The changelog lists all eleven breaking changes; these are the ones that need no action from you to bite:
Quotes in a string command are now consumed by tano, not by the child process. A command that relied on the child re-parsing them has to quote the inner command:
task('t', `pwsh -c echo 'Task 06'`); // 0.5
task('t', `pwsh -c "echo 'Task 06'"`); // 0.6Unquoted shell operators (&, |, ;, <, >, `, $() now throw instead of being passed on as literal arguments. Use needs to chain tasks, a code task instead of a pipe, quotes to pass an operator as a literal argument, or the array form.
A flag on the command line now wins over setup() in the tanofile. It used to be the other way round. If your tanofile sets logLevel, quiet or logOutput and you also pass the flag, the flag now decides.
source: true covers subdirectories. globstar defaulted to false, so ** behaved like * and every subdirectory was invisible to the hash. Tasks that were wrongly skipped now run, which makes a run take longer than before — that is the fix working, not a regression.
A failing run exits with 1. Every run used to exit with 0. A pipeline that was green because tano never failed will now go red.
The cache is not migrated. The first run after the update rebuilds it and leaves the old .tano/cache.db behind, which you can delete.
Create a TypeScript file with the name tanofile.ts and import the 'task' function and create your tasks.
import { needs, task } from 'jsr:@dx/tano';
task('pre-task', `echo 'These were ...'`);
task('default', needs('pre-task'), `echo '...two tasks.'`);Tasks can carry a description, which tano --list shows:
task('build', `deno check`, { description: 'Type checks everything' });Execute default task:
tanoExecute my-task:
tano --task my-task...or shorthand:
tano my-taskList all tasks of the tanofile:
tano --listThe same list is available in code, sorted by name, as plain data:
import { handler } from 'jsr:@dx/tano';
import './tanofile.ts';
handler.list(); // [{ name: 'build', description: 'Type checks everything', needs: [] }]Show what a task would run, without running it:
tano --dry-run my-taskA run that fails exits with 1, so tano can be used in a pipeline.
Run independent tasks at the same time:
tano --concurrency 4Tasks that do not depend on each other run together, up to the given number. The default is 1. Anything above that requires every ordering your tanofile relies on to be declared with needs — while tasks run at the same time, their output is prefixed with the task name so it stays readable:
docs | rendering page 1
build | compiling module 1
build | compiling module 2
docs | rendering page 2
Run a task again whenever something changes:
tano --watch my-task
tano --watch='src/**' my-taskWithout a glob everything below the tanofile is watched. Which tasks actually run again is decided by source, so declaring it keeps a watch run cheap.
Ctrl+C stops the running tasks instead of leaving the spawned processes behind. A task can also carry its own limit:
task('flaky', `deno run ./fetch.ts`, { timeout: 30_000 });tano runs commands without a shell. A string command is split into arguments, where single and double quotes group their content and a backslash is an ordinary character, so Windows paths can be written as they are:
task('t', `deno run "C:\\Program Files\\build.ts"`);Shell operators are not available, because there is no shell. Use needs to chain tasks, a code task instead of a pipe, or pass the command as an array of arguments:
task('t', ['sh', '-c', 'ls -la | wc -l']);setup sets the configuration from within the tanofile:
import { setup } from 'jsr:@dx/tano';
setup({
logLevel: 'DEBUG',
});A flag passed on the command line wins over setup, which in turn wins over the built-in defaults.
tano --help