-
Notifications
You must be signed in to change notification settings - Fork 110
fix(cli): quote the cmd.exe command path with real quotes on Windows #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KassaSana
wants to merge
3
commits into
firecrawl:main
Choose a base branch
from
KassaSana:fix/windows-cmd-command-quoting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+105
−3
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| mkdirSync, | ||
| mkdtempSync, | ||
| readFileSync, | ||
| rmSync, | ||
| writeFileSync, | ||
| } from 'fs'; | ||
| import os from 'os'; | ||
| import path from 'path'; | ||
| import { runClientCommand } from '../../commands/setup'; | ||
|
|
||
| // Spawns a real cmd.exe, unlike setup.test.ts which mocks child_process. | ||
| describe.runIf(process.platform === 'win32')( | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||
| 'runClientCommand on Windows (real cmd.exe)', | ||
| () => { | ||
| it.each([ | ||
| ['spaces and parentheses', 'Program Files (x86)'], | ||
| // cmd.exe expands %VAR% even inside quotes, so the path must not be | ||
| // rewritten to the variable's value. | ||
| ['a %VAR% sequence', 'dir %USERNAME% x'], | ||
| ['a %VAR% sequence without spaces', 'dir%USERNAME%x'], | ||
| ])( | ||
| 'launches a .cmd shim under a path with %s and passes argv through exactly', | ||
| (_, dirName) => { | ||
| const root = mkdtempSync(path.join(os.tmpdir(), 'firecrawl-spawn-')); | ||
| const bin = path.join(root, dirName, 'nodejs'); | ||
| const outFile = path.join(root, 'argv.json'); | ||
| try { | ||
| mkdirSync(bin, { recursive: true }); | ||
| writeFileSync( | ||
| path.join(bin, 'record-argv.js'), | ||
| 'require("fs").writeFileSync(process.env.ARGV_OUT, JSON.stringify(process.argv.slice(2)));\n' | ||
| ); | ||
| writeFileSync( | ||
| path.join(bin, 'record-argv.cmd'), | ||
| '@echo off\r\nnode "%~dp0record-argv.js" %*\r\n' | ||
| ); | ||
| const args = [ | ||
| '--name', | ||
| 'firecrawl', | ||
| 'https://mcp.firecrawl.dev/v2/mcp?a=1&b=2', | ||
| 'Authorization: Bearer ${FIRECRAWL_API_KEY}', | ||
| ]; | ||
|
|
||
| runClientCommand(path.join(bin, 'record-argv.cmd'), args, { | ||
| stdio: 'pipe', | ||
| env: { ...process.env, ARGV_OUT: outFile }, | ||
| }); | ||
|
|
||
| expect(JSON.parse(readFileSync(outFile, 'utf8'))).toEqual(args); | ||
| } finally { | ||
| rmSync(root, { recursive: true, force: true }); | ||
| } | ||
| } | ||
| ); | ||
| } | ||
| ); | ||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: This new job runs on every push to main/master as well as PRs, spending a Windows VM and a full
pnpm installto execute only three tests. Gate it withif: github.event_name == 'pull_request', matching the other add-on jobs in this file (test-binaryandtest-npm-package).Prompt for AI agents