Skip to content

Commit ed337e6

Browse files
steven-supersolidJcarlosjunior
authored andcommitted
Change arg check from truthy to defined (parse-community#3143)
Show log on master when using cluster
1 parent 9dbc35b commit ed337e6

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

spec/CLI.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ describe('commander additions', () => {
6363

6464
it('should load properly use args over env', (done) => {
6565
commander.loadDefinitions(testDefinitions);
66-
commander.parse(['node','./CLI.spec.js','--arg0', 'arg0Value', '--arg4', 'anotherArg4'], {
66+
commander.parse(['node','./CLI.spec.js','--arg0', 'arg0Value', '--arg4', ''], {
6767
'PROGRAM_ARG_0': 'arg0ENVValue',
6868
'PROGRAM_ARG_1': 'arg1ENVValue',
6969
'PROGRAM_ARG_2': '4',
70+
'PROGRAM_ARG_4': 'arg4ENVValue'
7071
});
7172
expect(commander.arg0).toEqual('arg0Value');
7273
expect(commander.arg1).toEqual('arg1ENVValue');
7374
expect(commander.arg2).toEqual(4);
74-
expect(commander.arg4).toEqual('anotherArg4');
75+
expect(commander.arg4).toEqual('');
7576
done();
7677
});
7778

src/cli/parse-server.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import runner from './utils/runner';
99
const help = function(){
1010
console.log(' Get Started guide:');
1111
console.log('');
12-
console.log(' Please have a look at the get started guide!')
12+
console.log(' Please have a look at the get started guide!');
1313
console.log(' https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide');
1414
console.log('');
1515
console.log('');
@@ -35,7 +35,7 @@ function startServer(options, callback) {
3535

3636
app.use(options.mountPath, api);
3737

38-
var server = app.listen(options.port, callback);
38+
let server = app.listen(options.port, callback);
3939
server.on('connection', initializeConnections);
4040

4141
if (options.startLiveQueryServer || options.liveQueryServerOptions) {
@@ -69,7 +69,7 @@ function startServer(options, callback) {
6969
}
7070
}
7171

72-
var handleShutdown = function() {
72+
let handleShutdown = function() {
7373
console.log('Termination signal received. Shutting down.');
7474
destroyAliveConnections();
7575
server.close(function () {
@@ -112,7 +112,8 @@ runner({
112112
if (options.cluster) {
113113
const numCPUs = typeof options.cluster === 'number' ? options.cluster : os.cpus().length;
114114
if (cluster.isMaster) {
115-
for(var i = 0; i < numCPUs; i++) {
115+
logOptions();
116+
for(let i = 0; i < numCPUs; i++) {
116117
cluster.fork();
117118
}
118119
cluster.on('exit', (worker, code) => {
@@ -132,6 +133,6 @@ runner({
132133
});
133134
}
134135
}
135-
})
136+
});
136137

137138
/* eslint-enable no-console */

src/cli/utils/commander.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Command.prototype.loadDefinitions = function(definitions) {
4747
});
4848
console.log('');
4949
});
50-
}
50+
};
5151

5252
function parseEnvironment(env = {}) {
5353
return Object.keys(_reverseDefinitions).reduce((options, key) => {
@@ -86,19 +86,19 @@ function parseConfigFile(program) {
8686
if (action) {
8787
options[key] = action(value);
8888
}
89-
})
89+
});
9090
console.log(`Configuration loaded from ${jsonPath}`)
9191
}
9292
return options;
9393
}
9494

9595
Command.prototype.setValuesIfNeeded = function(options) {
9696
Object.keys(options).forEach((key) => {
97-
if (!this[key]) {
97+
if (!this.hasOwnProperty(key)) {
9898
this[key] = options[key];
9999
}
100100
});
101-
}
101+
};
102102

103103
Command.prototype._parse = Command.prototype.parse;
104104

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

118118
Command.prototype.getOptions = function() {
119119
return Object.keys(_definitions).reduce((options, key) => {
@@ -122,7 +122,7 @@ Command.prototype.getOptions = function() {
122122
}
123123
return options;
124124
}, {});
125-
}
125+
};
126126

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

0 commit comments

Comments
 (0)