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

Support lerna execution from subdirectories of repo root #687

Merged
merged 13 commits into from
Mar 17, 2017

Conversation

evocateur
Copy link
Member

A few high-level goals, here:

  • lerna init should be the only time we (maybe) run git init.
  • lerna commands should ensure they are run in a git repo during the validation phase, not instantiation.
  • Use more "lazy" getters to avoid wasted work and streamline the command startup path.
  • Use high-quality libraries (find-up, load-json-file) instead of rolling our own.

fixes #645, #555

@evocateur
Copy link
Member Author

This PR is based on #664. Many thanks @noherczeg!

let stdout = child.execSync(command, mergedOpts);
if (stdout) {
// stdout is undefined when stdio[1] is anything other than "pipe"
// and there's no point trimming an empty string (no piped stdout)
Copy link
Member Author

Choose a reason for hiding this comment

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

I encountered this issue when I ignored stderr in GitUtilities.isInitialized(). That was a fun debugging session.

@@ -83,8 +96,8 @@ export default class Command {
}

runValidations() {
if (this.concurrency < 1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out that this block could never be entered because of the way we currently interpret the sort option.

return this.lernaJson && this.lernaJson.version;
}

get publishConfig() {
Copy link
Member Author

Choose a reason for hiding this comment

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

The publishConfig and bootstrapConfig properties are already handled by Command.getOptions(), so it seemed safe to remove these.

const deps = pkg[depsKey];
const {exact} = this.getOptions();
Copy link
Member Author

Choose a reason for hiding this comment

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

It was bugging me that we were calling this every time, even if there were no deps.

@evocateur evocateur changed the title feat: Support lerna execution from subdirectories of repo root Support lerna execution from subdirectories of repo root Mar 17, 2017
@evocateur evocateur merged commit 1eba53b into lerna:master Mar 17, 2017
@evocateur evocateur deleted the use-findup-for-lerna-root branch March 17, 2017 22:45
@@ -83,8 +96,8 @@ export default class Command {
}

runValidations() {
if (this.concurrency < 1) {
this.logger.warn("command must be run with at least one thread.");
if (!GitUtilities.isInitialized()) {

Choose a reason for hiding this comment

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

Hi @evocateur,

Just testing the upgrade path from v1-beta.36 to v2-rc.4 and come across this check. We noticed it as it started breaking on CI where it copies a previously cloned repo to another area to perform more tasks (rather than cloning again).

I'm sure we can change our build setup easy enough - but I was just wondering what the reason is as to why Lerna needs to be executed in a git repo or if this check could be dropped?

Thanks for your help

@evocateur
Copy link
Member Author

evocateur commented May 8, 2017 via email

@lock
Copy link

lock bot commented Dec 27, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lerna init on an empty folder don't generate any file
2 participants