Skip to content

Commit

Permalink
fix(dev): fix custom commands not working in dev console
Browse files Browse the repository at this point in the history
Before this fix, running a custom command within the `dev` command's
interactive command line would fail.
  • Loading branch information
thsig committed Aug 2, 2024
1 parent c045254 commit 621e96d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions core/src/cli/command-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { bindActiveContext, withSessionContext } from "../util/open-telemetry/co
import { wrapActiveSpan } from "../util/open-telemetry/spans.js"
import { DEFAULT_BROWSER_DIVIDER_WIDTH } from "../constants.js"
import { styles } from "../logger/styles.js"
import type { GardenCli } from "./cli.js"

const defaultMessageDuration = 3000
const commandLinePrefix = styles.warning("🌼 > ")
Expand Down Expand Up @@ -153,11 +154,14 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
private globalConfigStore: GlobalConfigStore
private readonly log: Log
private readonly globalOpts: Partial<ParameterValues<GlobalOptions>>
// TODO: Make this required (doing this will unfortunately involve fixing hundreds of unit tests)
private readonly cli: GardenCli | undefined

constructor({
cwd,
manager,
log,
cli,
globalOpts,
serveCommand,
extraCommands,
Expand All @@ -166,6 +170,7 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
cwd: string
manager: GardenInstanceManager
log: Log
cli: GardenCli | undefined
globalOpts: Partial<ParameterValues<GlobalOptions>>
serveCommand: ServeCommand
extraCommands: Command[]
Expand All @@ -178,6 +183,7 @@ export class CommandLine extends TypedEventEmitter<CommandLineEvents> {
this.cwd = cwd
this.manager = manager
this.log = log
this.cli = cli
this.globalOpts = globalOpts
this.extraCommands = extraCommands
this.serveCommand = serveCommand
Expand Down Expand Up @@ -778,6 +784,7 @@ ${styles.accent.underline("Keys:")}
.run({
...prepareParams,
garden,
cli: this.cli,
sessionId,
parentSessionId: this.manager.sessionId,
})
Expand Down
3 changes: 2 additions & 1 deletion core/src/commands/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Use ${styles.bold("up/down")} arrow keys to scroll through your command history.
}

private async initCommandHandler(params: ActionParams) {
const { garden, log, opts } = params
const { garden, log, opts, cli } = params

// override the session for this manager to ensure we inherit from
// the initial garden dummy instance
Expand All @@ -209,6 +209,7 @@ Use ${styles.bold("up/down")} arrow keys to scroll through your command history.
extraCommands: [new HelpCommand(), new QuitCommand(quit), new QuietCommand(), new QuiteCommand()],
globalOpts: pick(opts, Object.keys(globalOptions)),
history: await garden.localConfigStore.get("devCommandHistory"),
cli,
serveCommand: this,
})
this.commandLine = cl
Expand Down

0 comments on commit 621e96d

Please sign in to comment.