fix(core): Remove flawed safety check in getUserArgs and debug log
- Fixed bug where CLI with no args would return entire argv including node path - Removed debug 'Wanted command: ...' log from startParse()
This commit is contained in:
@@ -136,7 +136,6 @@ export class Smartcli {
|
||||
console.log(this.version || 'unknown version');
|
||||
return;
|
||||
}
|
||||
console.log(`Wanted command: ${wantedCommand}`);
|
||||
for (const command of this.commandObservableMap.getArray()) {
|
||||
if (!wantedCommand) {
|
||||
const standardCommand = this.commandObservableMap.findSync((commandArg) => {
|
||||
|
||||
@@ -63,14 +63,9 @@ export function getUserArgs(argv?: string[]): string[] {
|
||||
offset = Math.min(2, a.length);
|
||||
}
|
||||
|
||||
// Safety: if offset would skip all elements and array is not empty, don't skip anything
|
||||
// This handles edge cases like test environments with unusual argv setups
|
||||
if (offset >= a.length && a.length > 0) {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
// Note: we intentionally avoid path/URL heuristics on argv[1] so we don't
|
||||
// accidentally drop the first user arg when it's a path-like value in compiled mode.
|
||||
// When offset >= a.length, this correctly returns an empty array (no user args).
|
||||
return a.slice(offset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user