Skip to content

Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.

fix(install): reject unknown flags before installing (#18)

Ming956c8eeb4345
diff --git a/bin/install.js b/bin/install.js
index 5423a6a..1329f28 100755
--- a/bin/install.js
+++ b/bin/install.js
@@ -49,6 +49,16 @@ if (args.includes("--help") || args.includes("-h")) {
return;
}
+const withValue = ["--agent", "--dir"];
+const known = [...withValue, "--project", "--help", "-h"];
+for (let i = 0; i < args.length; i++) {
+ if (withValue.includes(args[i])) i++;
+ else if (args[i].startsWith("-") && !known.includes(args[i])) {
+ console.error(`Unknown option ${args[i]}\n\n${usage}`);
+ process.exit(1);
+ }
+}
+
function removeOldSkill(base) {
const old = path.join(base, "unslopovich");
try {
diff --git a/test/detect.test.js b/test/detect.test.js
index c554c41..13a6772 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -243,3 +243,29 @@ test("the installer replaces a skill folder from before the rename", () => {
fs.rmSync(dir, { recursive: true, force: true });
}
});
+
+test("the installer rejects an unknown flag before it copies anything", () => {
+ const fs = require("fs");
+ const os = require("os");
+ const { spawnSync } = require("child_process");
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), "unslop-home-"));
+ try {
+ const run = (...flags) =>
+ spawnSync(process.execPath, [path.join(__dirname, "..", "bin", "install.js"), ...flags], {
+ env: { ...process.env, HOME: home, USERPROFILE: home },
+ encoding: "utf8",
+ });
+ const typo = run("--projet");
+ assert.strictEqual(typo.status, 1);
+ assert.match(typo.stderr, /Unknown option --projet/);
+ assert.match(typo.stderr, /Usage:/);
+ assert.deepStrictEqual(fs.readdirSync(home), []);
+ const short = run("-x");
+ assert.strictEqual(short.status, 1);
+ assert.match(short.stderr, /Unknown option -x/);
+ assert.strictEqual(run("--help").status, 0);
+ assert.strictEqual(run("--agent", "nope").status, 1);
+ } finally {
+ fs.rmSync(home, { recursive: true, force: true });
+ }
+});