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

Update this reference to self #3137

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion lib/launchers/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function ProcessLauncher (spawn, tempDir, timer, processKillTimeout) {
return self._clearTempDirAndReportDone('no binary')
}

cmd = this._normalizeCommand(cmd)
cmd = self._normalizeCommand(cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

@devoto13, @johnjbarton
What do you thinks about that ? I did something opposite here:
#3157

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.

Consider this example: https://jsfiddle.net/devoto13/1ptvhgxn/

Apparently the only case, where it has incorrect this is when method is passed as callback by reference (i.e. .then(myClass.myMethod)) or similar, which is ultimately shooting yourself in the foot. So I think your (@lusarz's) way is good as long as we (and consumers) avoid this pattern.

But maybe I'm missing something. @Itee can you provide a more complete example of when this breaks?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But note that changes from self to this can potentially be breaking to the third-party code, which uses the mentioned pattern, so should probably go into a major version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @devoto13 for great input - I'll analyze your example more precisely tomorrow, but I think I know what you mean.

That's true - it would be better to release major version with these changes


log.debug(cmd + ' ' + args.join(' '))
self._process = spawn(cmd, args)
Expand Down