diff --git a/cli_test.ts b/cli_test.ts index 3d4cb76..bccc687 100644 --- a/cli_test.ts +++ b/cli_test.ts @@ -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", @@ -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); diff --git a/src/load_config.ts b/src/load_config.ts index ef679b2..9bfdd7b 100644 --- a/src/load_config.ts +++ b/src/load_config.ts @@ -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; } diff --git a/test/task/deno.jsonc b/test/task/deno.jsonc new file mode 100644 index 0000000..f0a6103 --- /dev/null +++ b/test/task/deno.jsonc @@ -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! */'" + } +} \ No newline at end of file