-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Refactoring startApp to add callback as a parameter and removing redundant varaibles #14
Conversation
stopApp: true | ||
}); | ||
// preventing null waitpkg | ||
startAppOptions.waitPkg = startAppOptions.waitPkg || startAppOptions.pkg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this handled by the default case above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you might want to clone before defaulting to avoid side effects.
startAppOptions = _.clone(startAppOptions);
_default(...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlipps no defaults only handles undefined. Earlier code had a comment for null so thought to handle it explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have cloned startAppOptions but still have null check in place , @jlipps any ideas if we still need the null check, since defaults will only handle undefined, it was explicitly commented about the null check.
@moiz, write your own default helper. function cloneAndDefault(opts, defaults) {
opts = _(opts).clone();
_(opts).each(function(val, key) { opts[key] = opts[key] || defaults[key];});
return opts;
} |
@sebv when values are set to false they would turn to true if default is true, so may be this looks better?
i was trying to tab in here so closed it by mistake :( |
|
I think
|
updated as per suggestions :) |
|
||
var stop = stopApp ? "-S" : ""; | ||
ADB.prototype.startApp = function (startAppOptions, cb) { | ||
var cloneAndDefaults = function (opts, defaults) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a generally useful function. Maybe we should include it up top or in a helper file. If we're just doing it here there's no need to make it a general function; we could just operate directly on startAppOptions
.
Refactoring startApp to add callback as a parameter and removing redundant varaibles
kill process fo freeing port
-Refactoring startApp to add callback as a parameter and removing redundant varaibles.
-Related to #2026