From 68e2869d645b2588b1c5ce2045bb7663bdd3fa5d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 7 Nov 2021 02:38:38 -0800 Subject: [bun run] Filter out `post*` and `pre*` from the completions --- src/cli/run_command.zig | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index af8fae0c8..952209a6b 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -433,7 +433,23 @@ pub const RunCommand = struct { } } - for (scripts.keys()) |key| { + const keys = scripts.keys(); + var key_i: usize = 0; + loop: while (key_i < keys.len) : (key_i += 1) { + const key = keys[key_i]; + + if (filter == Filter.script_exclude) { + for (reject_list) |default| { + if (std.mem.eql(u8, default, key)) { + continue :loop; + } + } + } + + if (strings.startsWith(key, "post") or strings.startsWith(key, "pre")) { + continue :loop; + } + var entry_item = results.getOrPutAssumeCapacity(key); if (filter == Filter.script_and_descriptions and max_description_len > 0) { -- cgit v1.2.3