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(fileList): refactor with async/await #3247

Merged
merged 1 commit into from
Jan 4, 2019
Merged

refactor(fileList): refactor with async/await #3247

merged 1 commit into from
Jan 4, 2019

Conversation

lusarz
Copy link
Contributor

@lusarz lusarz commented Jan 2, 2019

No description provided.

lib/file-list.js Outdated
@@ -74,7 +74,7 @@ class FileList {
return
}

return Promise
const files = await Promise
.filter(mg.found, (path) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This array mg.found and the function are synchronous, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rewrote this code, please check once again

lib/file-list.js Outdated
@@ -95,13 +95,12 @@ class FileList {
return this._preprocess(file).then(() => file)
Copy link
Contributor

Choose a reason for hiding this comment

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

The map() operates on a sync array, returning either a sync array or an array of promises. I guess sync Array.map() works fine for that somewhat funky operation. It would be less funky if we return Promise.resolve(file) in the nocache branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rewrote this code, please check once again


if (_.isEmpty(files)) {
log.warn(`All files matched by "${pattern}" were excluded or matched by prior matchers.`)
}
})
.then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The then resolution function is confusing and which promise chain we are resolving is confusing: can we find a better way? At least removing a nesting level might help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately I don't have now idea how to rewrite it

@lusarz lusarz merged commit 376142e into karma-runner:master Jan 4, 2019
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.

2 participants