Repository navigation
fix: run custom generator commands in the generator cwd and clean their output - #486
Closed
aaaxingiiiiiii wants to merge 1 commit into
Closed
aaaxingiiiiiii wants to merge 1 commit into
aaaxingiiiiiii wants to merge 1 commit into
Conversation
…ir output
Custom generators receive executeShellCommand and call it themselves.
When they did not pass a cwd, the command ran in the inshellisense
process directory instead of the terminal's current directory, and the
raw output (with trailing newlines and CRLF) was returned. Specs written
for Fig rely on both: npm's workspaces generator runs `npm prefix` and
reads `${stdout}/package.json`, which failed.
Fig runs commands without a working directory in the shell's current
directory, and cleans the output (CRLF to LF, strip leading and trailing
newlines). Do the same for the executeShellCommand passed to custom
generators. Script generators are unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Custom generators receive
executeShellCommandand call it themselves. This change fixes two problems with how those calls run.Working directory. When a custom generator did not pass a
cwd, its command ran in the inshellisense process directory rather than the terminal's current directory. After the usercds elsewhere in the wrapped shell, these generators query the wrong directory.Output. The generators received raw output, including the trailing newline and any CRLF. Specs written for Fig depend on cleaned output. For example, npm's workspaces generator runs
npm prefixand then reads`${stdout}/package.json`. The trailing newline ends up inside that path, sonpm run -w <Tab>never lists workspaces.Fig handles both cases:
working_directory()incrates/figterm/src/message.rs).executeCommandcleans the output: CRLF becomes LF, and leading and trailing newlines are removed (cleanOutputinpackages/api-bindings-wrappers/src/executeCommand.ts). Both files are in aws/amazon-q-developer-cli-autocomplete.This change does the same for the
executeShellCommandpassed to custom generators. Script generators are unchanged; they already receivecwdand usestdout.trim().Test plan
src/tests/runtime/generator.test.ts: default cwd, explicit cwd is kept, and output cleaning. Without the fix, the default-cwd and output-cleaning tests fail.npm run buildandnpm run lintpass.brewInstallMullvad, which also fails on unmodifiedmainon my machine because the local Homebrew prints no casks.npm run -win a project withworkspacesnow lists them.🤖 Generated with Claude Code