Skip to content

Commit

Permalink
feat: support deno task
Browse files Browse the repository at this point in the history
  • Loading branch information
kidonng committed Jul 2, 2022
1 parent b980624 commit 4dd990e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cli_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { assertEquals, assertMatch, assertStringIncludes } from "./dev_deps.ts";
const yamlWd = "./test/yaml";
const tsWd = "./test/ts";
const jsonWd = "./test/json";
const taskWd = "./test/task";
const cliArgs = [
"deno",
"run",
Expand Down Expand Up @@ -47,11 +48,16 @@ Deno.test("ts config file", async () => {
assertStringIncludes(output, expectedOutput);
});

Deno.test("deno.json(c) config file", async () => {
Deno.test("deno.json(c) config file with `velociraptor` field", async () => {
const output = await runScript("test", jsonWd);
assertStringIncludes(output, expectedOutput);
});

Deno.test("deno.json(c) config file with `task` field", async () => {
const output = await runScript("test", taskWd);
assertStringIncludes(output, expectedOutput);
});

Deno.test("deno run", async () => {
const output = await runScript("denorun");
assertStringIncludes(output, expectedOutput);
Expand Down
4 changes: 2 additions & 2 deletions src/load_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ async function parseDenoConfig(
(m, g) => g ? "" : m,
);
}
const { velociraptor: config = {} } = JSON.parse(content);
return config as ScriptsConfiguration;
const { velociraptor, tasks } = JSON.parse(content);
return (velociraptor || (tasks ? { scripts: tasks } : {})) as ScriptsConfiguration;
}
14 changes: 14 additions & 0 deletions test/task/deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Used to test that --config option is working properly
"lint": {
"rules": {
"exclude": ["no-explicit-any"]
}
},
/*
* Section below contains Velociraptor configuration
*/
"tasks": {
"test": "echo '/* Works! */'"
}
}

0 comments on commit 4dd990e

Please sign in to comment.