export { abort, debug, DrakeError, env, glob, log, outOfDate, quote, readFile, sh, shCapture, ShCaptureOpts, ShOpts, ShOutput, touch, updateFile, writeFile,} from "./lib/utils.ts";export { desc, execute, run, task, vers };
import { existsSync } from "https://deno.land/std@v0.41.0/fs/mod.ts";import * as path from "https://deno.land/std@v0.41.0/path/mod.ts";import { help } from "./lib/help.ts";import { Action, TaskRegistry } from "./lib/tasks.ts";import { abort, env, parseEnv } from "./lib/utils.ts";
const DRAKE_VERS = "0.41.0";
env("--abort-exits", true);
const taskRegistry = new TaskRegistry();
parseEnv(Deno.args.slice(), env);
if (env("--help")) { help();} else if (env("--version")) { console.log(vers());} else { let drakefile = env("--drakefile") ?? "Drakefile.ts"; if (!path.isAbsolute(drakefile)) { drakefile = path.join(Deno.cwd(), drakefile); } env("--drakefile", drakefile);
if (env("--directory")) { const dir = env("--directory"); if (!existsSync(dir) || !Deno.statSync(dir).isDirectory) { abort(`--directory missing or not a directory: ${dir}`); } Deno.chdir(dir); }}
function vers(): string { return DRAKE_VERS;}
function desc(description: string): void { taskRegistry.desc(description);}
function task( name: string, prereqs: string[] = [], action?: Action,): void { taskRegistry.register(name, prereqs, action);}
async function run(...names: string[]) { if (env("--help") || env("--version")) { return; } if (env("--list-tasks") || env("--list-all")) { taskRegistry.list().forEach((t) => console.log(t)); } else { if (names.length === 0) { names = env("--tasks"); if (names.length === 0 && env("--default-task")) { names.push(env("--default-task")); } } if (names.length === 0) { abort("no task specified"); } await taskRegistry.run(...names); }}
async function execute(...names: string[]) { await taskRegistry.execute(...names);}