aboutsummaryrefslogtreecommitdiff
path: root/src/shared/catalog.js
diff options
context:
space:
mode:
authorSoccera1 <[email protected]>2026-07-18 09:27:17 +1000
committerSoccera1 <[email protected]>2026-07-18 09:27:17 +1000
commit6f5241afb5bd1d6a1a8724bf06cc6f205c279402 (patch)
tree2aa852e968f6b89f2c8458333ce3e7c38b3c2450 /src/shared/catalog.js
parenta753f669c9bedfccb9f7f400da018bb487dca5d0 (diff)
downloadbnu-6f5241afb5bd1d6a1a8724bf06cc6f205c279402.tar.gz
bnu-6f5241afb5bd1d6a1a8724bf06cc6f205c279402.zip
Refactor to single call
Diffstat (limited to 'src/shared/catalog.js')
-rw-r--r--src/shared/catalog.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/shared/catalog.js b/src/shared/catalog.js
new file mode 100644
index 0000000..1d0f1de
--- /dev/null
+++ b/src/shared/catalog.js
@@ -0,0 +1,27 @@
+export const commandNames = Object.freeze([
+ "[", "arch", "b2sum", "base32", "base64", "basename", "basenc", "cat",
+ "chcon", "chgrp", "chmod", "chown", "chroot", "cksum", "comm", "coreutils",
+ "cp", "csplit", "cut", "date", "dd", "df", "dir", "dircolors", "dirname", "du",
+ "echo", "env", "expand", "expr", "factor", "false", "fmt", "fold", "ginstall",
+ "groups", "head", "hostid", "hostname", "id", "install", "join", "kill", "link",
+ "ln", "logname", "ls", "md5sum", "mkdir", "mkfifo", "mknod", "mktemp", "mv",
+ "nice", "nl", "nohup", "nproc", "numfmt", "od", "paste", "pathchk", "pinky",
+ "pr", "printenv", "printf", "ptx", "pwd", "readlink", "realpath", "rm", "rmdir",
+ "runcon", "seq", "sha1sum", "sha224sum", "sha256sum", "sha384sum", "sha512sum",
+ "shred", "shuf", "sleep", "sm3sum", "sort", "split", "stat", "stdbuf", "stty",
+ "sum", "sync", "tac", "tail", "tee", "test", "timeout", "touch", "tr", "true",
+ "truncate", "tsort", "tty", "uname", "unexpand", "uniq", "unlink", "uptime",
+ "users", "vdir", "wc", "who", "whoami", "yes",
+]);
+
+const commandSet = new Set(commandNames);
+
+export function hasCommand(name) {
+ return commandSet.has(name);
+}
+
+export async function loadCommand(name) {
+ if (!hasCommand(name)) return null;
+ const path = new URL(`../commands/${encodeURIComponent(name)}.js`, import.meta.url);
+ return (await import(path.href)).default;
+}