mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 11:59:27 +08:00
use a better method
This commit is contained in:
parent
f924f06df7
commit
df3c5ab402
|
@ -1,20 +1,4 @@
|
|||
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')"
|
||||
complete -f -c deno -n "__fish_seen_subcommand_from task" -n "__fish_is_nth_token 2" -a "(NO_COLOR=1 deno task &| string match -rg '^- (\S*)')"
|
||||
|
|
Loading…
Reference in New Issue
Block a user