-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Use local lerna if available #1122
Use local lerna if available #1122
Conversation
closes lerna#138 BREAKING CHANGE lerna now prefers installs resolvable relative to the current working directory. For situations where a global install was used and an outdated lerna version is present in the node_modules folder, this might cause breakage. The issue can be resolved by installing a lerna version that fulfills the version requirement in lerna.json
cd55ee6
to
5af9075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on!
bin/lerna.js
Outdated
@@ -1,4 +1,6 @@ | |||
#!/usr/bin/env node | |||
"use strict"; | |||
const resolveCwd = require("resolve-cwd"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the (more recent) import-local pattern, which encapsulates the tricky stuff for us:
const importLocal = require("import-local");
if (importLocal(__filename)) {
require("npmlog").verbose("cli", "using local version of lerna");
} else {
require("../lib/cli")().parse(process.argv.slice(2));
}
test/cli.js
Outdated
it("should throw without command", async () => { | ||
try { | ||
await bin([]); | ||
fail(`Expected an exception, but it didn"t throw anything`); // eslint-disable-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does fail
come from? Seems a little odd to templatize a string that isn't interpolated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail
is exposed by jasmine. I changed those to match the jest recommendations: https://facebook.github.io/jest/docs/en/tutorial-async.html#async-await
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's why I didn't recognize it. I really wish we could upgrade to Jest 21, but something in Jest 20 broke how we run the integration tests...
So, about the "breaking change"-ness... I don't see this change as breaking for existing calls from npm scripts, which is (especially in CI) by far the most common usage? I agree that it does constitute a very different flow for those that call I suppose I should suck it up and sketch out a 3.0 milestone, bundling a few more breaking changes (#174, ...?). |
Yeah, scratched my head quite a bit on categorizing this, too. I tend to play it safe with semver and mark changes as breaking as soon as there is potential breakage, especially in uncommon usage scenarios (e.g. global installation, even on CI). My personal approach to major releases is to handle them in no special way, so I'd release this without waiting for other changes. Def. your call though. |
If people using lerna as a CLI with some API and you breaking this API then it's breaking. If you don't breaking this API — then it's not. upd: Same for CI, btw. |
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
This will change the CLI behaviour to use
lerna
from the nearestnode_modules
relative toprocess.cwd()
if available.Motivation and Context
package.json
How Has This Been Tested?
Types of changes
Checklist:
Breaking Change:
lerna now prefers installs resolvable relative to the current working directory.
For situations where a global install was used and an outdated lerna version
is present in the node_modules folder, this might cause breakage.
The issue can be resolved by installing a lerna version that fulfills the version
requirement in lerna.json