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(watcher): refactor watcher.js #2979

Merged
merged 1 commit into from
May 4, 2018
Merged

refactor(watcher): refactor watcher.js #2979

merged 1 commit into from
May 4, 2018

Conversation

lusarz
Copy link
Contributor

@lusarz lusarz commented Apr 22, 2018

This pull request simplify a bit logic in watcher.js method.

Copy link
Member

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

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

thank you, some small things

lib/watcher.js Outdated
return p !== path && path.substr(0, p.length + 1) === p + DIR_SEP
})) {
pathsToWatch.forEach(path => {
if (![...pathsToWatch].some(p => p !== path && path.substr(0, p.length + 1) === p + DIR_SEP)) {
Copy link
Member

Choose a reason for hiding this comment

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

this is very inefficient doing the conversion to an array inside the loop

lib/watcher.js Outdated
function getWatchedPatterns (patterns) {
return patterns
.filter(pattern => pattern.watched)
.map(pattern => pattern.pattern)
Copy link
Member

Choose a reason for hiding this comment

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

while we are changing this code, lets use use either reduce, a for loop or underscore to avoid doing two iterations

lib/watcher.js Outdated
.on('add', path => fileList.addFile(helper.normalizeWinPath(path)))
.on('change', path => fileList.changeFile(helper.normalizeWinPath(path)))
.on('unlink', path => fileList.removeFile(helper.normalizeWinPath(path)))
.on('error', log.debug)
Copy link
Member

Choose a reason for hiding this comment

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

better to do log.debug.bind(log) to be on the safe side here

@lusarz
Copy link
Contributor Author

lusarz commented Apr 23, 2018

@dignifiedquire
Thanks for feedback, I've provided changes you asked for

@lusarz
Copy link
Contributor Author

lusarz commented May 1, 2018

AppVeyor (only Node v4) fails with error, that seems to not be related with this PR. Any idea how to fix ?

@johnjbarton
Copy link
Contributor

Actually node 4 fails then appveyor bails and no tests run on other versions.

I think this is related to #2951

Copy link
Member

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

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

thank you, looks like the windows issue is unrelated

@dignifiedquire dignifiedquire merged commit 6c355f1 into karma-runner:master May 4, 2018
@lusarz lusarz deleted the refactor-watcher branch May 26, 2018 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants