Skip to content
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
5 changes: 3 additions & 2 deletions spec/CLI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ describe('commander additions', () => {

it('should load properly use args over env', (done) => {
commander.loadDefinitions(testDefinitions);
commander.parse(['node','./CLI.spec.js','--arg0', 'arg0Value', '--arg4', 'anotherArg4'], {
commander.parse(['node','./CLI.spec.js','--arg0', 'arg0Value', '--arg4', ''], {
'PROGRAM_ARG_0': 'arg0ENVValue',
'PROGRAM_ARG_1': 'arg1ENVValue',
'PROGRAM_ARG_2': '4',
'PROGRAM_ARG_4': 'arg4ENVValue'
});
expect(commander.arg0).toEqual('arg0Value');
expect(commander.arg1).toEqual('arg1ENVValue');
expect(commander.arg2).toEqual(4);
expect(commander.arg4).toEqual('anotherArg4');
expect(commander.arg4).toEqual('');
done();
});

Expand Down
11 changes: 6 additions & 5 deletions src/cli/parse-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import runner from './utils/runner';
const help = function(){
console.log(' Get Started guide:');
console.log('');
console.log(' Please have a look at the get started guide!')
console.log(' Please have a look at the get started guide!');
console.log(' https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide');
console.log('');
console.log('');
Expand All @@ -35,7 +35,7 @@ function startServer(options, callback) {

app.use(options.mountPath, api);

var server = app.listen(options.port, callback);
let server = app.listen(options.port, callback);
server.on('connection', initializeConnections);

if (options.startLiveQueryServer || options.liveQueryServerOptions) {
Expand Down Expand Up @@ -69,7 +69,7 @@ function startServer(options, callback) {
}
}

var handleShutdown = function() {
let handleShutdown = function() {
console.log('Termination signal received. Shutting down.');
destroyAliveConnections();
server.close(function () {
Expand Down Expand Up @@ -112,7 +112,8 @@ runner({
if (options.cluster) {
const numCPUs = typeof options.cluster === 'number' ? options.cluster : os.cpus().length;
if (cluster.isMaster) {
for(var i = 0; i < numCPUs; i++) {
logOptions();
for(let i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', (worker, code) => {
Expand All @@ -132,6 +133,6 @@ runner({
});
}
}
})
});

/* eslint-enable no-console */
12 changes: 6 additions & 6 deletions src/cli/utils/commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Command.prototype.loadDefinitions = function(definitions) {
});
console.log('');
});
}
};

function parseEnvironment(env = {}) {
return Object.keys(_reverseDefinitions).reduce((options, key) => {
Expand Down Expand Up @@ -86,19 +86,19 @@ function parseConfigFile(program) {
if (action) {
options[key] = action(value);
}
})
});
console.log(`Configuration loaded from ${jsonPath}`)
}
return options;
}

Command.prototype.setValuesIfNeeded = function(options) {
Object.keys(options).forEach((key) => {
if (!this[key]) {
if (!this.hasOwnProperty(key)) {
this[key] = options[key];
}
});
}
};

Command.prototype._parse = Command.prototype.parse;

Expand All @@ -113,7 +113,7 @@ Command.prototype.parse = function(args, env) {
this.setValuesIfNeeded(fromFile);
// Last set the defaults
this.setValuesIfNeeded(_defaults);
}
};

Command.prototype.getOptions = function() {
return Object.keys(_definitions).reduce((options, key) => {
Expand All @@ -122,7 +122,7 @@ Command.prototype.getOptions = function() {
}
return options;
}, {});
}
};

export default new Command();
/* eslint-enable no-console */