Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit b5dcccb

Browse files
author
sw-yx
committed
merge
1 parent 83b2536 commit b5dcccb

File tree

5 files changed

+88
-50
lines changed

5 files changed

+88
-50
lines changed

package-lock.json

Lines changed: 77 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
"bugs": "https://github.com/netlify/netlify-dev-plugin/issues",
77
"dependencies": {
88
"@netlify/cli-utils": "^1.0.1",
9+
"@netlify/rules-proxy": "^0.1.0",
910
"@netlify/zip-it-and-ship-it": "^0.1.3",
1011
"@oclif/command": "^1",
1112
"@oclif/config": "^1",
1213
"ascii-table": "0.0.9",
1314
"copy-template-dir": "^1.4.0",
15+
"execa": "^1.0.0",
1416
"fs-extra": "^7.0.1",
1517
"fuzzy": "^0.1.3",
1618
"get-port": "^4.1.0",
1719
"http-proxy": "^1.17.0",
1820
"inquirer": "^6.2.2",
1921
"inquirer-autocomplete-prompt": "^1.0.1",
2022
"netlify": "2.4.1",
21-
"@netlify/rules-proxy": "0.1.0",
2223
"node-fetch": "^2.3.0",
2324
"opn": "^5.5.0",
2425
"safe-join": "^0.1.2",

src/commands/dev/exec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { spawn } = require('child_process')
1+
const execa = require('execa')
22
const Command = require('@netlify/cli-utils')
33
const { getAddons } = require('netlify/src/addons')
44

@@ -15,7 +15,7 @@ class ExecCommand extends Command {
1515
}
1616
})
1717
}
18-
spawn(this.argv[0], this.argv.slice(1), { env: process.env, stdio: 'inherit' })
18+
execa(this.argv[0], this.argv.slice(1), { env: process.env, stdio: 'inherit' })
1919
}
2020
}
2121

src/commands/dev/index.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { flags } = require('@oclif/command')
2-
const { spawn } = require('child_process')
2+
const execa = require('execa')
33
const http = require('http')
44
const httpProxy = require('http-proxy')
55
const waitPort = require('wait-port')
@@ -11,10 +11,6 @@ const Command = require('@netlify/cli-utils')
1111
const { getAddons } = require('netlify/src/addons')
1212
const { track } = require('@netlify/cli-utils/src/utils/telemetry')
1313

14-
function cleanExit() {
15-
process.exit()
16-
}
17-
1814
function isFunction(settings, req) {
1915
return settings.functionsPort && req.url.match(/^\/.netlify\/functions\/.+/)
2016
}
@@ -99,22 +95,10 @@ function startDevServer(settings, log, error) {
9995
return
10096
}
10197

102-
const ps = spawn(settings.cmd, settings.args, { env: settings.env })
103-
104-
ps.stdout.on('data', data => {
105-
log(`${data}`.replace(settings.urlRegexp, `$1$2${settings.port}$3`))
106-
})
107-
108-
ps.stderr.on('data', data => {
109-
log(`Error reading data: ${data}`)
110-
})
111-
112-
ps.on('close', code => {
113-
process.exit(code)
114-
})
115-
116-
ps.on('SIGINT', cleanExit)
117-
ps.on('SIGTERM', cleanExit)
98+
const ps = execa(settings.cmd, settings.args, { env: settings.env, stdio: 'inherit', shell: true })
99+
ps.on('close', code => process.exit(code))
100+
ps.on('SIGINT', process.exit)
101+
ps.on('SIGTERM', process.exit)
118102
}
119103

120104
class DevCommand extends Command {

src/utils/openBrowser.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
var chalk = require('chalk')
66
var execSync = require('child_process').execSync
7-
var spawn = require('cross-spawn')
7+
var execa = require('execa')
88
var opn = require('opn')
99

1010
// https://github.com/sindresorhus/opn#app
@@ -37,9 +37,7 @@ function getBrowserEnv() {
3737

3838
function executeNodeScript(scriptPath, url) {
3939
const extraArgs = process.argv.slice(2)
40-
const child = spawn('node', [scriptPath, ...extraArgs, url], {
41-
stdio: 'inherit'
42-
})
40+
const child = spawn('node', [scriptPath, ...extraArgs, url], { stdio: 'inherit' })
4341
child.on('close', code => {
4442
if (code !== 0) {
4543
console.log()

0 commit comments

Comments
 (0)