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

minor bugfixes to https://github.com/netlify/netlify-dev-plugin/pull/67 #68

Merged
merged 1 commit into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/commands/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function startDevServer(settings, log, error) {
return
}

const ps = execa(settings.cmd, settings.args, { env: settings.env, stdio: 'inherit', shell: true })
const ps = execa(settings.command, settings.args, { env: settings.env, stdio: 'inherit', shell: true })
ps.on('close', code => process.exit(code))
ps.on('SIGINT', process.exit)
ps.on('SIGTERM', process.exit)
Expand Down Expand Up @@ -133,7 +133,7 @@ class DevCommand extends Command {
}
process.env.NETLIFY_DEV = 'true'
let settings = serverSettings(config.dev)
if (!(settings && settings.cmd)) {
if (!(settings && settings.command)) {
this.log('No dev server detected, using simple static server')
const dist = (config.dev && config.dev.publish) || (config.build && config.build.publish)
settings = {
Expand Down
12 changes: 5 additions & 7 deletions src/detect-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ module.exports.serverSettings = devConfig => {
settings = settings || {}
if (devConfig.command) {
settings.command = devConfig.command.split(/\s/)[0]
assignLoudly(devConfig, 'command', settings, 'command')
assignLoudly(settings, 'command', devConfig, 'command')
settings.args = devConfig.command.split(/\s/).slice(1)
assignLoudly(devConfig, 'args', settings, 'args')
}
if (devConfig.port) {
assignLoudly(devConfig, 'port', settings, 'proxyPort')
assignLoudly(settings, 'proxyPort', devConfig, 'port')
settings.urlRegexp = devConfig.urlRegexp || new RegExp(`(http://)([^:]+:)${devConfig.port}(/)?`, 'g')
}
assignLoudly(devConfig, 'publish', settings, 'dist')
assignLoudly(settings, 'dist', devConfig, 'publish')
}

return settings
}

// does assignAndTellUserIfNetlifyTomlDevBlockOverride
// mutates the settings field
function assignLoudly(devConfig, field, settings, settingsField) {
// mutates the settings field from the devConfig field, but tell the user if it does
function assignLoudly(settings, settingsField, devConfig, field) {
if (settings[settingsField] !== devConfig[field]) {
// silent if command is exactly same
console.log(`Using ${field} from netlify.toml [dev] block: `, devConfig[field])
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

```ts
{
cmd: String, // e.g. yarn, npm
command: String, // e.g. yarn, npm
port: Number, // e.g. 8888
proxyPort: Number, // e.g. 3000
env: Object, // env variables, see examples
Expand Down