Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/utils/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export const runCommand = (
const { cwd, env = {}, spinner } = options
const commandProcess = execa.command(command, {
preferLocal: true,
// Command strings in netlify.toml may use shell operators like `&&`.
// execa.command() does not interpret these unless shell mode is enabled.
shell: true,
Comment on lines 69 to +73
// we use reject=false to avoid rejecting synchronously when the command doesn't exist
reject: false,
env: {
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/framework-detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ describe.concurrent('frameworks/framework-detection', () => {
})
})

test('should support shell operators in `command`', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({ config: { dev: { command: 'echo first && echo second', targetPort: 3000 } } })
.build()

try {
await withDevServer({ cwd: builder.directory }, async () => {}, true)
// a failure is expected since this command does not start a server
t.expect.unreachable()
} catch (err) {
t.expect(err).toHaveProperty('stdout')
const output = normalizeSnapshot((err as execa.ExecaReturnValue).stdout, { duration: true, filePath: true })
t.expect(output).toMatch(/\nfirst\s*\r?\n\s*second\r?\n/i)
t.expect(output).not.toMatch(/\nfirst\s*&&\s*echo\s+second\r?\n/i)
}
})
})

test('should force a specific framework when configured', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder.withNetlifyToml({ config: { dev: { framework: 'create-react-app' } } }).build()
Expand Down
Loading