Update deno task completions to handle deno.jsonc and package.json

This commit is contained in:
sigmaSd 2023-03-21 21:21:35 +01:00 committed by Mahmoud Al-Qudsi
parent da3323bbc2
commit 93bf4e1187

View file

@ -1,2 +1,24 @@
deno completions fish | source
complete -f -c deno -n "__fish_seen_subcommand_from task" -a "(deno eval \"try {console.log(Object.keys(JSON.parse(Deno.readTextFileSync('deno.json')).tasks).join('\n'))} catch {} \")"
# complete deno task
set searchForDenoFilesCode '
const denoFile = ["deno.json", "deno.jsonc", "package.json"];
for (const file of denoFile) {
try {
Deno.statSync(file);
// file exists
if (file === "package.json") {
console.log(
Object.keys(JSON.parse(Deno.readTextFileSync(file)).scripts).join("\n"),
);
} else {
console.log(
Object.keys(JSON.parse(Deno.readTextFileSync(file)).tasks).join("\n"),
);
}
break;
} catch {
}
}
'
complete -f -c deno -n "__fish_seen_subcommand_from task" -a "(deno eval '$searchForDenoFilesCode')"