fish-shell/share/completions/deno.fish
sigmaSd 25f16f0bfd fix deno task completion for jsonc
(cherry picked from commit f924f06df7)
2023-12-31 12:18:48 +08:00

20 lines
637 B
Fish

deno completions fish | source
# complete deno task
set searchForDenoFilesCode '
import * as JSONC from "https://deno.land/std@0.208.0/jsonc/mod.ts";
// order matters
const denoFile = ["deno.json", "deno.jsonc", "package.json"];
for (const file of denoFile) {
try {
Deno.statSync(file);
// file exists
const props = file === "package.json" ? "scripts" : "tasks";
console.log(
Object.keys(JSONC.parse(Deno.readTextFileSync(file))[props]).join("\n"),
);
break;
} catch {}
}
'
complete -f -c deno -n "__fish_seen_subcommand_from task" -n "__fish_is_nth_token 2" -a "(deno eval '$searchForDenoFilesCode')"