lerna changed returns ambiguous code
See original GitHub issueIn our continuous integration pipeline we use lerna changed --include-merged-tags --loglevel=silent --json
to collect changed packages for the next step. When there are no changes, this command fails with a return code of 1 and an empty result. In this case we still want to go on executing the build process. However, lately there was an invalid package.json
file in one of the packages. Turns out lerna returns the same result (error code 1, empty result) in this case, too. This caused a faulty build.
As a user, it would be really helpful to be able to distinguish between response being “no changes” or “invalid files”, for example, based on the response code.
Our current workaround is to do a lerna list
first, that fails only when there are invalid files.
Expected Behavior
lerna changed
returns a different code for no changes, and for errors
Current Behavior
lerna changed
returns the same error response in both scenarios
Possible Solution
Return a different response code for these cases.
Steps to Reproduce (for bugs)
- run
lerna changed --include-merged-tags --loglevel=silent --json
with a brokenpackage.json
in one of the projects (make the json invalid) - run it without changes in the projects
- compared outputs are the same
lerna.json
{
"lerna": "3.0.0",
"packages": [
"packages/*"
],
"version": "independent",
"command": {
"publish": {
"ignoreChanges": [
"**/package-lock.json"
],
"registry": "https://artifactory-us.prezi.com/api/npm/npm/",
"bump": "patch"
}
}
}
lerna-debug.log
0 silly argv { _: [ 'changed' ],
0 silly argv 'include-merged-tags': true,
0 silly argv includeMergedTags: true,
0 silly argv loglevel: 'silent',
0 silly argv json: true,
0 silly argv composed: 'changed',
0 silly argv lernaVersion: '3.4.2',
0 silly argv '$0': 'node_modules/.bin/lerna' }
1 notice cli v3.4.2
2 verbose rootPath /Users/csuvikg/projects/frontend-packages
3 info versioning independent
4 error JSONError: Unexpected string in JSON at position 2790 while parsing '{ "name": "@prezi/viewer-lite", "ver' in packages/viewer-lite/package.json
4 error at module.exports (/Users/csuvikg/projects/frontend-packages/node_modules/parse-json/index.js:26:19)
4 error at parse (/Users/csuvikg/projects/frontend-packages/node_modules/load-json-file/index.js:8:29)
Context
Your Environment
Executable | Version |
---|---|
lerna --version |
3.4.2 |
npm --version |
6.4.1 |
yarn --version |
1.15.2 |
node --version |
v10.10.0 |
OS | Version |
---|---|
macOS Mojave | 10.14.5 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top GitHub Comments
Agree with @endreymarcell as I’m facing the same issue.
lerna changed
is trying to detect changes and the response might be list of changed packages, and it’s should be acceptablet to have empty list, but this should be list anyway. And from program execution standpoint - program completed correctly and expects such conditions, so nothing prevent’s it from functioning correctly, therefore there shouldn’t be any error code emit. Meanwhile broken packages or anything that potentially breaks following program execution reasonable to throw and return error code.Hi Folks 👋
You will have seen in our message above that we at Nrwl are working really hard to bring the lerna repo up to date with what matters most to its community in June 2022.
As previously stated in that message, because we have not heard from the original author of this issue within the last 14 days, we are now automatically closing it.
If any users, including the original author, are still impacted by this issue then we still want to hear from you!
All we ask is that you first update to the latest lerna (
5.1.4
at the time of writing) to make sure it is still reproducible, and then fill out one of our new issue templates, providing all the requested details which apply to your situation:https://github.com/lerna/lerna/issues/new/choose
Many thanks again! 🙏
P.S. Over and above getting to grips with the repo, we have also been hard at work launching a new website, resolving all vulnerabilities, merging exciting new features and reigniting community PR contributions! 🚀
You can read our recent blog post to learn more about what we’ve been up to: https://blog.nrwl.io/lerna-5-1-new-website-new-guides-new-lerna-example-repo-distributed-caching-support-and-speed-64d66410bec7