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

Commit b062da4

Browse files
authored
Merge pull request #68 from netlify/makeDetectorsSafer
minor bugfixes to #67
2 parents 9b364eb + c75aff6 commit b062da4

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/commands/dev/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function startDevServer(settings, log, error) {
9696
return
9797
}
9898

99-
const ps = execa(settings.cmd, settings.args, { env: settings.env, stdio: 'inherit', shell: true })
99+
const ps = execa(settings.command, settings.args, { env: settings.env, stdio: 'inherit', shell: true })
100100
ps.on('close', code => process.exit(code))
101101
ps.on('SIGINT', process.exit)
102102
ps.on('SIGTERM', process.exit)
@@ -133,7 +133,7 @@ class DevCommand extends Command {
133133
}
134134
process.env.NETLIFY_DEV = 'true'
135135
let settings = serverSettings(config.dev)
136-
if (!(settings && settings.cmd)) {
136+
if (!(settings && settings.command)) {
137137
this.log('No dev server detected, using simple static server')
138138
const dist = (config.dev && config.dev.publish) || (config.build && config.build.publish)
139139
settings = {

src/detect-server.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@ module.exports.serverSettings = devConfig => {
1717
settings = settings || {}
1818
if (devConfig.command) {
1919
settings.command = devConfig.command.split(/\s/)[0]
20-
assignLoudly(devConfig, 'command', settings, 'command')
20+
assignLoudly(settings, 'command', devConfig, 'command')
2121
settings.args = devConfig.command.split(/\s/).slice(1)
22-
assignLoudly(devConfig, 'args', settings, 'args')
2322
}
2423
if (devConfig.port) {
25-
assignLoudly(devConfig, 'port', settings, 'proxyPort')
24+
assignLoudly(settings, 'proxyPort', devConfig, 'port')
2625
settings.urlRegexp = devConfig.urlRegexp || new RegExp(`(http://)([^:]+:)${devConfig.port}(/)?`, 'g')
2726
}
28-
assignLoudly(devConfig, 'publish', settings, 'dist')
27+
assignLoudly(settings, 'dist', devConfig, 'publish')
2928
}
3029

3130
return settings
3231
}
3332

34-
// does assignAndTellUserIfNetlifyTomlDevBlockOverride
35-
// mutates the settings field
36-
function assignLoudly(devConfig, field, settings, settingsField) {
33+
// mutates the settings field from the devConfig field, but tell the user if it does
34+
function assignLoudly(settings, settingsField, devConfig, field) {
3735
if (settings[settingsField] !== devConfig[field]) {
3836
// silent if command is exactly same
3937
console.log(`Using ${field} from netlify.toml [dev] block: `, devConfig[field])

src/detectors/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
```ts
88
{
9-
cmd: String, // e.g. yarn, npm
9+
command: String, // e.g. yarn, npm
1010
port: Number, // e.g. 8888
1111
proxyPort: Number, // e.g. 3000
1212
env: Object, // env variables, see examples

0 commit comments

Comments
 (0)