Skip to content

Commit

Permalink
Dev: Resolve command before spawning (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaeesBhatti authored Apr 12, 2020
1 parent 3a2bf59 commit 8102806
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"update-notifier": "^2.5.0",
"uuid": "^3.3.3",
"wait-port": "^0.2.2",
"which": "^2.0.2",
"winston": "^3.2.1",
"wrap-ansi": "^6.0.0",
"write-file-atomic": "^3.0.0"
Expand Down
7 changes: 4 additions & 3 deletions src/commands/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const http = require('http')
const httpProxy = require('http-proxy')
const waitPort = require('wait-port')
const getPort = require('get-port')
const which = require('which')
const chokidar = require('chokidar')
const proxyMiddleware = require('http-proxy-middleware')
const cookie = require('cookie')
Expand Down Expand Up @@ -320,7 +321,7 @@ function serveRedirect(req, res, proxy, match, options) {
return proxy.web(req, res, options)
}

function startDevServer(settings, log) {
async function startDevServer(settings, log) {
if (settings.noCmd) {
const StaticServer = require('static-server')

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

log(`${NETLIFYDEVLOG} Starting Netlify Dev with ${settings.type}`)
const args = settings.command === 'npm' ? ['run', ...settings.args] : settings.args
const ps = child_process.spawn(settings.command, args, {
const ps = child_process.spawn(await which(settings.command), args, {
env: { ...settings.env, FORCE_COLOR: 'true' },
stdio: settings.stdio || 'inherit',
detached: true,
Expand Down Expand Up @@ -436,7 +437,7 @@ class DevCommand extends Command {
}
settings.port = port

startDevServer(settings, this.log)
await startDevServer(settings, this.log)

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

0 comments on commit 8102806

Please sign in to comment.