Skip to content

Conversation

Perchusha
Copy link

Problem

On Windows, Storybook’s Symfony integration was using child_process.exec() to run commands formatted as one big, single‑quoted string (e.g. ’php’ ’bin/console’ …). In cmd.exe, single quotes aren’t treated as delimiters, so the command fails with:

’’php’’ is not recognized as an internal or external command…

See issue #43 for details.

Solution

This PR replaces the fragile exec(string) approach with child_process.spawn() and an explicit argument array.

  • Cross‑platform: passing command and args[] directly avoids any quoting/parsing quirks on Windows, macOS or Linux.
  • Readability: the code now clearly separates the executable (php) from its arguments (bin/console, debug:container, etc.).
  • Error handling: exit codes and stdout/stderr are captured and surfaced exactly as before.

What’s Changed

  • Removed: import { exec } from 'child_process' and the old execSymfonyCommand(finalCommand: string) function body.
  • Added: import { spawn } from 'child_process' and a new execSymfonyCommand(command: string, args: string[]): Promise that uses spawn(..., { shell: true }).
  • Updated: runSymfonyCommandJson (and any direct callers) to call execSymfonyCommand('php', ['bin/console', command, …]) instead of building a single interpolated string.
  • Tests: manually verified on Windows 10 and Linux; npm run build and npm run storybook now succeed without quoting errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant