Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for apps key in config file, throws if length is > 1 #979

Merged
merged 2 commits into from
Mar 17, 2016
Merged
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
20 changes: 14 additions & 6 deletions src/cli/parse-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ program.loadDefinitions(definitions);

program
.usage('[options] <path/to/configuration.json>');

program.on('--help', function(){
console.log(' Get Started guide:');
console.log('');
Expand All @@ -31,19 +31,27 @@ program.on('--help', function(){
console.log(' $ parse-server -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log('');
});

program.parse(process.argv, process.env);

let options = {};
if (program.args.length > 0 ) {
let jsonPath = program.args[0];
jsonPath = path.resolve(jsonPath);
options = require(jsonPath);
let jsonConfig = require(jsonPath);
if (jsonConfig.apps) {
if (jsonConfig.apps.length > 1) {
throw 'Multiple apps are not supported';
}
options = jsonConfig.apps[0];
} else {
options = jsonConfig;
}
console.log(`Configuation loaded from ${jsonPath}`)
}
}

options = Object.keys(definitions).reduce(function (options, key) {
if (program[key]) {
if (typeof program[key] !== 'undefined') {
options[key] = program[key];
}
return options;
Expand All @@ -66,7 +74,7 @@ const api = new ParseServer(options);
app.use(options.mountPath, api);

var server = app.listen(options.port, function() {

for (let key in options) {
let value = options[key];
if (key == "masterKey") {
Expand Down