cli-setu 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/setu.js +20 -0
- package/package.json +1 -1
package/bin/setu.js
CHANGED
|
@@ -29,7 +29,27 @@ const args = process.argv.slice(2);
|
|
|
29
29
|
const firstArg = args[0];
|
|
30
30
|
const isSubcommand = firstArg && !firstArg.startsWith('-');
|
|
31
31
|
|
|
32
|
+
// Real bug found by testing: a genuinely unrecognized flag like `-rfesfd`
|
|
33
|
+
// or `-g` (a typo, not meant for supervisor.js at all) also starts with
|
|
34
|
+
// "-", so it fell through the isSubcommand check above straight into the
|
|
35
|
+
// bare-`cli-setu` session-watching path below - silently pairing/starting
|
|
36
|
+
// a real session and generating a QR code instead of telling the user
|
|
37
|
+
// their command doesn't exist. supervisor.js only ever actually reads
|
|
38
|
+
// `--cli <name>` out of argv (confirmed by reading it directly - the
|
|
39
|
+
// `[workingDir]` mentioned in its own old comment is dead, WORKING_DIR is
|
|
40
|
+
// just process.cwd()) - every other `-`-prefixed flag is unrecognized by
|
|
41
|
+
// definition, same as an unrecognized subcommand already is below.
|
|
42
|
+
const KNOWN_FLAGS = new Set(['--version', '-v', '--help', '-h', '--update', '--cli']);
|
|
43
|
+
const hasUnknownFlag = args.some((a) => a.startsWith('-') && !KNOWN_FLAGS.has(a));
|
|
44
|
+
|
|
32
45
|
async function main() {
|
|
46
|
+
if (hasUnknownFlag) {
|
|
47
|
+
const bad = args.find((a) => a.startsWith('-') && !KNOWN_FLAGS.has(a));
|
|
48
|
+
console.error(`[cli-setu] Unknown option: ${bad}`);
|
|
49
|
+
console.error('[cli-setu] For more info, run: cli-setu --help');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
if (args.includes('--version') || args.includes('-v')) {
|
|
34
54
|
console.log(require('../package.json').version);
|
|
35
55
|
return;
|