Run tasks in Deno. Supports serial and parallel execution.
$ deno install -A devo https://denopkg.com/iamnathanj/[email protected]/cli.ts
$ devo [taskname]
If no task name is provided, devo will look for a task named default
. (see below)
Create a task file in the root of your project called devo.ts
.
// devo.ts
import { task, parallel, series } from "https://denopkg.com/iamnathanj/[email protected]/mod.ts";
const JS = "rollup -c";
const CSS = "sass src/styles:dist/css --watch";
const SERVER = "deno --allow-net server.ts";
task("rollup", JS);
task("scss", CSS);
task("server", SERVER);
parallel("dev", ["server", "rollup", "scss"]);
series("default", ["dev"]);
Tasks are composable in series
or parallel
. These methods are also composable with each other. This means you can build complex process chains.
import { task, parallel, series } from "https://denopkg.com/iamnathanj/[email protected]/mod.ts";
task("task1", "echo 1");
task("task2", "echo 2");
task("task3", "echo 3");
parallel("parallel-task1", ["task1", "task2", "task3"]);
parallel("parallel-task2", ["task1", "task2", "task3"]);
series("composed-task", ["parallel-task1", "parallel-task2"]);
Tasks can be referenced by string name (as shown above), but can also be written inline.
series("composed", [
parallel("parallel-task1", [
task("task1", "echo 1"),
task("task2", "echo 2")
]),
task("delay", "sleep 3"),
parallel("parallel-task2", [
task("task3", "echo 3"),
task("task4", "echo 4")
])
]);
Devo currently supports watching on task
s only. Simply call task(...).watch()
to recursively watch Deno.cwd()
for changes to .ts
, .tsx
, and .js
files.
Or, you can set explicit WatchOptions.
task("server", SERVER).watch({
batch: true,
root: `${Deno.cwd()}/src`,
walkOptions: {
exts: [".ts", ".tsx", ".js", "jsx", "json"]
}
});
Just like npm
scripts, devo
will augment your PATH
to run executables. You can use devo install
to install executables locally to <project>/.deno/bin
. This way, you can invoke them from tasks without a global install.
$ devo install foo <https://module.url/foo.ts> [permissions]
// devo.ts
import { task } from "https://denopkg.com/iamnathanj/[email protected]/mod.ts";
task("run-foo", "foo");
Similarly, devo will add <project>/node_modules/.bin
to your path if you want to run a node based task.
$ npm i -D @babel/core @babel/cli
// devo.ts
import { task } from "https://denopkg.com/iamnathanj/[email protected]/mod.ts";
task("js", "babel src -d dist");
If you install the devo
executable, then it will take care of running tasks from your devo.ts
file. If you prefer, you can call .run
on any of the devo exports. This means you can use any file name you want or create your own runner.
task("task1", "echo 1");
task("task2", "echo 2");
task("task3", "echo 3");
task("sleep", "sleep 3");
// you can call run on `task`, `series`, or `parallel`
await parallel("parallel-task", ["task1", "task2", "task3"]).run();
// or assign it to a variable and run it later
const composed = series("composed-task", [
"sleep",
"parallel-task",
"sleep",
"parallel-task"
]);
await composed.run();