gu
Experimental task runner, inspired by the Guardian’s ergonomic but unorthodox use of
makefiles.
Note
This is still very much in development, although it should work…
If you find a bug, please open an issue.
The idea is to standardise how and where you define project tasks, by making them:
- easy to discover
- simple to run
- flexible to write
It’s inspired by a lot of prior art, especially GitHub’s Scripts To Rule Them All.
N.B. while gu is only intended to be used by humans (and not by CI systems
etc), it’s designed to encourage a style of writing tasks that also makes them
simple to run in CI.
Screenshot
Installation
For now, you’ll need to install
guusing Deno. See deno.land if you need to install Deno as well.
deno install --allow-read --allow-run https://deno.land/x/gu_cli/gu.tsUsage
gu <task> [<task> ...] [-- args...]Examples
gu testYou can run multiple tasks:
gu test lint # will be run serially, in orderYou can pass arguments to individual tasks by quoting them:
gu test 'lint --cache'You can pass arguments to all tasks by passing them after --:
gu test lint -- --cacheTasks can also be globs:
gu 'build-*' # run all tasks in ./scripts/ that start with "build-"
gu '**/test' # run all 'test' tasks in ./scripts/, including subdirectories
gu '**/*' # run all tasks in ./scriptsHelpers
gu comes with some built in helpers that can be used in your tasks.
--verify-node
Ensure the correct version of Node is being used (based on .nvmrc).
More to come…
Flags
--list, -l
List all available tasks in the current directory.
--help, -h
Show help.
--version, -v
Show the version number.
Tasks
Tasks are any executable files that live in the ./scripts directory.
Note that file extensions are ignored by
gu, so having bothlint.rbandlint.mjswould throw an error.
Example
.scripts/
├── build.mjs #!/usr/bin/env node
├── lint #!/usr/bin/env ruby
└── test #!/usr/bin/env bashNow you can run:
gu lint test buildSpecial Tasks
Gu will also run any relevant before-*/after-* scripts it finds in
./scripts/.gu/.
For example, if you run gu build, it will try to run the following:
./scripts/.gu/before-all./scripts/.gu/before-build./scripts/build./scripts/.gu/after-build./scripts/.gu/after-all
These can be useful to set up your environment before running a task, or to clean up afterwards etc.
Development
You will need Deno. See deno.land for more information.
While developing, instead of running gu you can run ./gu.ts instead.
Building
To build gu, run the project’s build script using gu itself:
./gu.ts build