From 81028066a899ce5ceb7e8f964bbbd7bb9509d6a4 Mon Sep 17 00:00:00 2001 From: Raees Iqbal Date: Sun, 12 Apr 2020 14:03:11 -0700 Subject: [PATCH] Dev: Resolve command before spawning (#816) --- package.json | 1 + src/commands/dev/index.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index cf83cc90bef..a5a320958b1 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/commands/dev/index.js b/src/commands/dev/index.js index 2530bb49147..67675b7bf44 100644 --- a/src/commands/dev/index.js +++ b/src/commands/dev/index.js @@ -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') @@ -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') @@ -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, @@ -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