Skip to content

Commit 8102806

Browse files
authored
Dev: Resolve command before spawning (#816)
1 parent 3a2bf59 commit 8102806

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
"update-notifier": "^2.5.0",
139139
"uuid": "^3.3.3",
140140
"wait-port": "^0.2.2",
141+
"which": "^2.0.2",
141142
"winston": "^3.2.1",
142143
"wrap-ansi": "^6.0.0",
143144
"write-file-atomic": "^3.0.0"

src/commands/dev/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const http = require('http')
88
const httpProxy = require('http-proxy')
99
const waitPort = require('wait-port')
1010
const getPort = require('get-port')
11+
const which = require('which')
1112
const chokidar = require('chokidar')
1213
const proxyMiddleware = require('http-proxy-middleware')
1314
const cookie = require('cookie')
@@ -320,7 +321,7 @@ function serveRedirect(req, res, proxy, match, options) {
320321
return proxy.web(req, res, options)
321322
}
322323

323-
function startDevServer(settings, log) {
324+
async function startDevServer(settings, log) {
324325
if (settings.noCmd) {
325326
const StaticServer = require('static-server')
326327

@@ -341,7 +342,7 @@ function startDevServer(settings, log) {
341342

342343
log(`${NETLIFYDEVLOG} Starting Netlify Dev with ${settings.type}`)
343344
const args = settings.command === 'npm' ? ['run', ...settings.args] : settings.args
344-
const ps = child_process.spawn(settings.command, args, {
345+
const ps = child_process.spawn(await which(settings.command), args, {
345346
env: { ...settings.env, FORCE_COLOR: 'true' },
346347
stdio: settings.stdio || 'inherit',
347348
detached: true,
@@ -436,7 +437,7 @@ class DevCommand extends Command {
436437
}
437438
settings.port = port
438439

439-
startDevServer(settings, this.log)
440+
await startDevServer(settings, this.log)
440441

441442
// serve functions from zip-it-and-ship-it
442443
// env variables relies on `url`, careful moving this code

0 commit comments

Comments
 (0)