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

Add a utility function to execute hooks serially #814

Merged
merged 2 commits into from Mar 24, 2018

Conversation

malept
Copy link
Member

@malept malept commented Mar 20, 2018

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

Adds serialHooks(hooks) (ported from Electron Forge), which allows a user to run hooks serially instead of in parallel (which was added in v10.0.0 due to Promise.all).

Closes #812.

test/hooks.js Outdated
}
const testHooks = [
() => { output += ' 1'; return Promise.resolve() },
timeoutFunc(2),
Copy link
Member

Choose a reason for hiding this comment

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

Can we use this in the above test as well

test/hooks.js Outdated

test('serialHooks executes functions serially', t => {
let output = '0'
const timeoutFunc = number => {
Copy link
Member

Choose a reason for hiding this comment

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

If this helper takes in the timeout as well we can remove more code duplication below for the hooks that instantly resolve

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 9dcc68c

@codecov
Copy link

codecov bot commented Mar 20, 2018

Codecov Report

Merging #814 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #814   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          11     12    +1     
  Lines         597    607   +10     
=====================================
+ Hits          597    607   +10
Impacted Files Coverage Δ
common.js 100% <ø> (ø) ⬆️
hooks.js 100% <100%> (ø)
platform.js 100% <100%> (ø) ⬆️
index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a02ccc0...9dcc68c. Read the comment docs.

@benlancaster
Copy link

This is great 👍

@malept malept merged commit e5116d0 into master Mar 24, 2018
@malept malept deleted the optional-sequential-hooks branch March 24, 2018 09:30
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