diff --git a/lib/forever/cli.js b/lib/forever/cli.js index e6a284aa..1ff13939 100644 --- a/lib/forever/cli.js +++ b/lib/forever/cli.js @@ -276,7 +276,8 @@ var getOptions = cli.getOptions = function (file) { ].join(' ')); } - function assignSpawnWith(options) { + function setDefaults(options) { + options = clone(options) options.sourceDir = options.sourceDir || (file && file[0] !== '/' ? process.cwd() : '/'); options.workingDir = options.workingDir || options.sourceDir; options.spawnWith = { cwd: options.workingDir }; @@ -285,11 +286,12 @@ var getOptions = cli.getOptions = function (file) { if (configs && configs.length) { return configs.map(function (conf) { - return assignSpawnWith(objectAssign(clone(options), conf)); + var startupConfig = setDefaults(objectAssign(clone(options), conf)); + return startupConfig; }); } - return [assignSpawnWith(options)]; + return [setDefaults(options)]; }; // diff --git a/test/fixtures/servers.json b/test/fixtures/servers.json index d97e0e67..b370c06a 100644 --- a/test/fixtures/servers.json +++ b/test/fixtures/servers.json @@ -3,13 +3,15 @@ "uid": "server1", "append": true, "script": "server.js", - "sourceDir": "./test/fixtures" + "sourceDir": "./test/fixtures", + "workingDir": "./" }, { "uid": "server2", "append": true, "script": "server.js", "sourceDir": "./test/fixtures", + "workingDir": "./", "args": ["-p", 8081] } ]