Skip to content

Conversation

@kentcdodds
Copy link
Collaborator

ref #48

child.on('exit', exitCode => cb(null, exitCode))
} else {
cb(child)
if (options.parallel) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like the code below could be greatly simplified with RxJS. But I have no idea how to use Observables. Someone please help me!

Choose a reason for hiding this comment

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

I don't really see an opportunity for observables. Might be missing something though. Why do you think observables make sense here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've never used Observables, but I thought that they're supposed to really help with complex async stuff. 🤷

Choose a reason for hiding this comment

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

I think it can be done a little bit cleaner though. I'll do a PR later today or this weekend.

Copy link

@ta2edchimp ta2edchimp Sep 3, 2016

Choose a reason for hiding this comment

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

Maybe zip is what you're looking for (re RxJS)? Merge multiple Observables/Promises, subscribe to the result and have a single handling of their results ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know what I'm looking for.. I just think this code could be cleaned up a bit...

Copy link

@SamVerschueren SamVerschueren Sep 3, 2016

Choose a reason for hiding this comment

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

When running in parallel, you can just use Promise.all, when executing serially you can do something like this.

const result = promises.reduce((res, task) => {
   return res.then(() => task());
}, Promise.resolve());

result.then(...);

@codecov-io
Copy link

codecov-io commented Sep 4, 2016

Current coverage is 100% (diff: 100%)

Merging #53 into master will not change coverage

@@           master   #53   diff @@
===================================
  Files          11    11          
  Lines         217   242    +25   
  Methods         0     0          
  Messages        0     0          
  Branches        0     0          
===================================
+ Hits          217   242    +25   
  Misses          0     0          
  Partials        0     0          

Powered by Codecov. Last update 00f9cba...a5c9b26

@kentcdodds
Copy link
Collaborator Author

kentcdodds commented Sep 4, 2016

Sweet I think this is good to ship

Could I get some people to test it? I've released it as the beta: npm install p-s@beta. Just make sure your stuff's not broken?

cc @boneskull, @tleunen, @nkbt, @DavidWells, @Hypercubed, @rowanoulton

This is a significant refactor and I'd hate to break anyone due to this bug fix! (Ref #48)

This is a significant refactor to make it so when an error occurs in one
parallel script, the others are killed and also to ensure that an error
in one serial script will result in the others not being executed.

Closes #48
@kentcdodds kentcdodds changed the title WIP: abort all processes when one fails abort all processes when one fails Sep 4, 2016
@kentcdodds
Copy link
Collaborator Author

:shipit:

@kentcdodds
Copy link
Collaborator Author

This is good to merge by anyone as soon as it's reviewed!

import Promise from 'bluebird'
import colors from 'colors/safe'
import {isString, find, clone} from 'lodash'
import {isString, clone} from 'lodash'

Choose a reason for hiding this comment

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

Full lodash is quite huge, why not install them separately?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I get you, but honestly I'm using about a dozen methods and I'd rather avoid installing each separately/managing them. It's 1.4MB (uncompressed) and the likelihood that someone's already depending on lodash in their project (even if it's transitively) is quite high.

Thanks for the suggestion.

@Hypercubed
Copy link
Contributor

I gave it a quick run on OSX and windows. No issues other than an unrelated issue on windows (where you aware that the command package-scripts fails on windows?).

So... LGTM.

@kentcdodds
Copy link
Collaborator Author

where you aware that the command package-scripts fails on windows?

Oh no! I wasn't. Could you file an issue for that? Thanks for testing it out @Hypercubed!

This updates the contributions for:

- @kentcdodds
- @tleunen
- @Hypercubed

It adds the following new contributors:

- @jisaacks
- @boneskull
- @RobinMalfait
- @edm00se
- @SamVerschueren

Thanks for the contributions everyone!
@kentcdodds
Copy link
Collaborator Author

:shipit:

@kentcdodds kentcdodds merged commit 6a2e93c into master Sep 4, 2016
@kentcdodds kentcdodds deleted the pr/async-kill branch September 4, 2016 15:56
@boneskull
Copy link
Contributor

haha, I need more than 22h notice 😉

@kentcdodds
Copy link
Collaborator Author

I guess I was anxious and excited :-)

@boneskull
Copy link
Contributor

Have you considered therapy? 😉

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.

7 participants