Skip to content

Commit

Permalink
fix: Merge pull request #84 from seamapi/back-command-fix
Browse files Browse the repository at this point in the history
Fix `[Back]` command bug where using a full command path made the CLI act in an unintended way
  • Loading branch information
andrii-balitskyi authored Jan 30, 2024
2 parents 3a6ef2a + 550482b commit 77e79d1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/interact-for-command-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ export async function interactForCommandSelection(
["select", "server"],
])

// Add dynamic 'back' command for sub-commands to allow returning
// to previous level.
if (commandPath.length > 0) {
commands.push([...commandPath, "[Back]"])
}

const possibleCommands = uniqBy(
commandPath.length === 0
? commands
Expand All @@ -54,6 +48,13 @@ export async function interactForCommandSelection(
) {
return commandPath
}

// Add dynamic 'back' command for sub-commands to allow returning
// to previous level.
if (commandPath.length > 0) {
possibleCommands.push([...commandPath, "[Back]"])
}

const commandPathStr = commandPath.join("/").replace(/-/g, "_")

const res = await prompts({
Expand Down

0 comments on commit 77e79d1

Please sign in to comment.