Change arg check from truthy to defined (#3143)
Show log on master when using cluster
This commit is contained in:
committed by
Florent Vilmart
parent
bd1689190f
commit
143bd11638
@@ -63,15 +63,16 @@ describe('commander additions', () => {
|
|||||||
|
|
||||||
it('should load properly use args over env', (done) => {
|
it('should load properly use args over env', (done) => {
|
||||||
commander.loadDefinitions(testDefinitions);
|
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_0': 'arg0ENVValue',
|
||||||
'PROGRAM_ARG_1': 'arg1ENVValue',
|
'PROGRAM_ARG_1': 'arg1ENVValue',
|
||||||
'PROGRAM_ARG_2': '4',
|
'PROGRAM_ARG_2': '4',
|
||||||
|
'PROGRAM_ARG_4': 'arg4ENVValue'
|
||||||
});
|
});
|
||||||
expect(commander.arg0).toEqual('arg0Value');
|
expect(commander.arg0).toEqual('arg0Value');
|
||||||
expect(commander.arg1).toEqual('arg1ENVValue');
|
expect(commander.arg1).toEqual('arg1ENVValue');
|
||||||
expect(commander.arg2).toEqual(4);
|
expect(commander.arg2).toEqual(4);
|
||||||
expect(commander.arg4).toEqual('anotherArg4');
|
expect(commander.arg4).toEqual('');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import runner from './utils/runner';
|
|||||||
const help = function(){
|
const help = function(){
|
||||||
console.log(' Get Started guide:');
|
console.log(' Get Started guide:');
|
||||||
console.log('');
|
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(' https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('');
|
console.log('');
|
||||||
@@ -35,7 +35,7 @@ function startServer(options, callback) {
|
|||||||
|
|
||||||
app.use(options.mountPath, api);
|
app.use(options.mountPath, api);
|
||||||
|
|
||||||
var server = app.listen(options.port, callback);
|
let server = app.listen(options.port, callback);
|
||||||
server.on('connection', initializeConnections);
|
server.on('connection', initializeConnections);
|
||||||
|
|
||||||
if (options.startLiveQueryServer || options.liveQueryServerOptions) {
|
if (options.startLiveQueryServer || options.liveQueryServerOptions) {
|
||||||
@@ -69,7 +69,7 @@ function startServer(options, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var handleShutdown = function() {
|
let handleShutdown = function() {
|
||||||
console.log('Termination signal received. Shutting down.');
|
console.log('Termination signal received. Shutting down.');
|
||||||
destroyAliveConnections();
|
destroyAliveConnections();
|
||||||
server.close(function () {
|
server.close(function () {
|
||||||
@@ -112,7 +112,8 @@ runner({
|
|||||||
if (options.cluster) {
|
if (options.cluster) {
|
||||||
const numCPUs = typeof options.cluster === 'number' ? options.cluster : os.cpus().length;
|
const numCPUs = typeof options.cluster === 'number' ? options.cluster : os.cpus().length;
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
for(var i = 0; i < numCPUs; i++) {
|
logOptions();
|
||||||
|
for(let i = 0; i < numCPUs; i++) {
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
}
|
}
|
||||||
cluster.on('exit', (worker, code) => {
|
cluster.on('exit', (worker, code) => {
|
||||||
@@ -132,6 +133,6 @@ runner({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ Command.prototype.loadDefinitions = function(definitions) {
|
|||||||
});
|
});
|
||||||
console.log('');
|
console.log('');
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function parseEnvironment(env = {}) {
|
function parseEnvironment(env = {}) {
|
||||||
return Object.keys(_reverseDefinitions).reduce((options, key) => {
|
return Object.keys(_reverseDefinitions).reduce((options, key) => {
|
||||||
@@ -86,7 +86,7 @@ function parseConfigFile(program) {
|
|||||||
if (action) {
|
if (action) {
|
||||||
options[key] = action(value);
|
options[key] = action(value);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
console.log(`Configuration loaded from ${jsonPath}`)
|
console.log(`Configuration loaded from ${jsonPath}`)
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
@@ -94,11 +94,11 @@ function parseConfigFile(program) {
|
|||||||
|
|
||||||
Command.prototype.setValuesIfNeeded = function(options) {
|
Command.prototype.setValuesIfNeeded = function(options) {
|
||||||
Object.keys(options).forEach((key) => {
|
Object.keys(options).forEach((key) => {
|
||||||
if (!this[key]) {
|
if (!this.hasOwnProperty(key)) {
|
||||||
this[key] = options[key];
|
this[key] = options[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
Command.prototype._parse = Command.prototype.parse;
|
Command.prototype._parse = Command.prototype.parse;
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ Command.prototype.parse = function(args, env) {
|
|||||||
this.setValuesIfNeeded(fromFile);
|
this.setValuesIfNeeded(fromFile);
|
||||||
// Last set the defaults
|
// Last set the defaults
|
||||||
this.setValuesIfNeeded(_defaults);
|
this.setValuesIfNeeded(_defaults);
|
||||||
}
|
};
|
||||||
|
|
||||||
Command.prototype.getOptions = function() {
|
Command.prototype.getOptions = function() {
|
||||||
return Object.keys(_definitions).reduce((options, key) => {
|
return Object.keys(_definitions).reduce((options, key) => {
|
||||||
@@ -122,7 +122,7 @@ Command.prototype.getOptions = function() {
|
|||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
};
|
||||||
|
|
||||||
export default new Command();
|
export default new Command();
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
|
|||||||
Reference in New Issue
Block a user