-
Notifications
You must be signed in to change notification settings - Fork 457
fix(dev): execute dev command with shell operators (&&, ||, etc.)
#8234
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
puneetdixit200
wants to merge
7
commits into
netlify:main
Choose a base branch
from
puneetdixit200:fix-dev-command-shell-operators-8228
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.
+131
−9
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
efb9991
fix(dev): run dev command through shell for operator support
805a8d0
Restore missing dev command detection
puneetdixit200 96d2c28
fix(dev): tighten command result guard
puneetdixit200 55dd679
fix: avoid misleading missing command hints
puneetdixit200 4f17001
fix(dev): avoid missing command hint for exit 127
puneetdixit200 024d61d
fix(dev): limit shell mode to compound commands
puneetdixit200 0f83ddd
test: cover shell command helpers
puneetdixit200 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
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,54 @@ | ||
| import { describe, expect, test } from 'vitest' | ||
|
|
||
| import { | ||
| canReportMissingCommandName, | ||
| getCommandName, | ||
| isNonExistingCommandError, | ||
| shouldUseShell, | ||
| } from '../../../src/utils/shell.js' | ||
|
|
||
| describe('shell command helpers', () => { | ||
| test('uses a shell only when command syntax requires it', () => { | ||
| expect(shouldUseShell('npm run dev')).toBe(false) | ||
| expect(shouldUseShell('echo first && echo second')).toBe(true) | ||
| expect(shouldUseShell('npm run build || npm run fallback')).toBe(true) | ||
| expect(shouldUseShell('FOO=1 npm run dev')).toBe(true) | ||
| }) | ||
|
|
||
| test('extracts quoted and unquoted command names', () => { | ||
| expect(getCommandName('npm run dev')).toBe('npm') | ||
| expect(getCommandName('"my command" --flag')).toBe('my command') | ||
| expect(getCommandName("'my command' --flag")).toBe('my command') | ||
| }) | ||
|
|
||
| test('does not report a single missing command for compound shell syntax', () => { | ||
| expect(canReportMissingCommandName('npm run dev')).toBe(true) | ||
| expect(canReportMissingCommandName('echo before && missing-command')).toBe(false) | ||
| expect(canReportMissingCommandName('FOO=1 missing-command')).toBe(false) | ||
| }) | ||
|
|
||
| test('detects missing command output without treating package managers as missing commands', () => { | ||
| expect( | ||
| isNonExistingCommandError({ | ||
| command: 'missing-command', | ||
| error: { stderr: 'sh: missing-command: command not found', exitCode: 127 }, | ||
| }), | ||
| ).toBe(true) | ||
|
|
||
| expect( | ||
| isNonExistingCommandError({ | ||
| command: 'npm', | ||
| error: { stderr: 'sh: npm: command not found', exitCode: 127 }, | ||
| }), | ||
| ).toBe(false) | ||
| }) | ||
|
|
||
| test('does not classify an existing command exit 127 as a missing command', () => { | ||
| expect( | ||
| isNonExistingCommandError({ | ||
| command: 'bash', | ||
| error: { shortMessage: 'Command failed with exit code 127: bash -c "exit 127"', exitCode: 127 }, | ||
| }), | ||
| ).toBe(false) | ||
| }) | ||
| }) |
Oops, something went wrong.
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.