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

refactor(launcher): use this directly instead assign to self variable in base launcher #3157

Merged
merged 1 commit into from
Oct 3, 2018
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
19 changes: 9 additions & 10 deletions lib/launchers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function BaseLauncher (id, emitter) {
this.state = null
this.error = null

const self = this
let killingPromise
let previousUrl

Expand All @@ -41,7 +40,7 @@ function BaseLauncher (id, emitter) {

this.error = null
this.state = BEING_CAPTURED
this.emit('start', url + '?id=' + this.id + (helper.isDefined(self.displayName) ? '&displayName=' + encodeURIComponent(self.displayName) : ''))
this.emit('start', url + '?id=' + this.id + (helper.isDefined(this.displayName) ? '&displayName=' + encodeURIComponent(this.displayName) : ''))
}

this.kill = function () {
Copy link
Collaborator

@devoto13 devoto13 Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also change this.start and this.kill to be arrow functions to be on the safe side. Not 100% sure, because of inheritance.

Expand All @@ -50,8 +49,8 @@ function BaseLauncher (id, emitter) {
return killingPromise
}

killingPromise = this.emitAsync('kill').then(function () {
self.state = FINISHED
killingPromise = this.emitAsync('kill').then(() => {
this.state = FINISHED
})

this.state = BEING_KILLED
Expand All @@ -75,17 +74,17 @@ function BaseLauncher (id, emitter) {
killingPromise = this.emitAsync('kill')
}

killingPromise.then(function () {
if (self.state === BEING_FORCE_KILLED) {
self.state = FINISHED
killingPromise.then(() => {
if (this.state === BEING_FORCE_KILLED) {
this.state = FINISHED
} else {
killingPromise = null
log.debug('Restarting %s', self.name)
self.start(previousUrl)
log.debug('Restarting %s', this.name)
this.start(previousUrl)
}
})

self.state = RESTARTING
this.state = RESTARTING
}

this.markCaptured = function () {
Expand Down