steveblue / angular2-rollup

CLI for bundling Angular with Rollup and Closure Compiler
121 stars 18 forks source link

ngr build always returning successful status code #34

Closed zolakt closed 5 years ago

zolakt commented 5 years ago

I'm testing this in windows powershell. It seems like the ngr command isn't exiting with a non-successful status code when it breaks,

I'm deliberately throwing exceptions in the pre and post hooks. The exception is printed to console, but the status code is still True. I've tried process.exit(1) instead of exceptions, same result. Tried to reject the promise in the hook, same result.

I'm testing the status using echo $?. It's always returning true

This is a problem in CI builds since we can't break the build and it continues to other stages.

zolakt commented 5 years ago

Reopening this issue, since I pinpointed the problem. The pre/post hooks work fine, as long as you do a process.exit(1) from them.

The problem is that the build process returns status 0 (success) for all unhanded errors. Basically, this line https://github.com/steveblue/angular2-rollup/blob/2fc2e81f29833196b0e25cc0cf50847d4506c0aa/index.js#L114

Should be this instead: if (options.exit) process.exit(1);

If you don't provide the argument to process.exit it defaults to 0, and it's treated as a success code. This makes a big deal in CI. We build a couple of apps sequentially, and if ngr fails, we can't stop the pipeline.,

Also, from the CI perspective, it would be cleaner to do console.error("") instead of console.log(colors.red, ""). Also errors should be written with process.stderr.write instead of process.stdout.write

steveblue commented 5 years ago

All valid points that should be addressed. There are plans to migrate angular-rollup to the new Builder API, but these are all valid changes for a hotfix release.

steveblue commented 5 years ago

If anyone wants this issue fixed soon please submit a PR.

steveblue commented 5 years ago

This is fixed on develop branch.

steveblue commented 5 years ago

Fixed in 2.0.4 release