Skip to content
Open
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
8 changes: 5 additions & 3 deletions lib/forever/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is correct btw - this gives config values higher priority than cli flags. Surely this should be reversed?

return startupConfig;
});
}

return [assignSpawnWith(options)];
return [setDefaults(options)];
};

//
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/servers.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
]