diff --git a/share/completions/deno.fish b/share/completions/deno.fish index ece7b9d6e..3c24cd005 100644 --- a/share/completions/deno.fish +++ b/share/completions/deno.fish @@ -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 {} \")" \ No newline at end of file + +# 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')"