fix(import): Ensure compatibility with root-level package globs #1875
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
lerna import
to work in the case where packages are housed at the root level of a lerna-managed repo and use a configuration like["myapp-*"]
for the packages configuration.Description
I changed the
getPackageDirectories()
method inside the import command so that any path ending in*
is considered a package root location instead of just the ones ending in/*
.Motivation and Context
This fixes #1872. The change makes it possible to use
lerna import
when your packages are located at the root directory of a lerna-managed repo.How Has This Been Tested?
I added a new test that covers the exact case failing in the issue I reported. The test makes a new lerna repo with the
myapp-*
config, imports a subpackage, and then verifies the new history and file contents.I had to add a new testing helper since having a static name for the test repo wasn't supported by the regular fixtures helper function.
I wrote the test before the implementation, verified it failed, wrote the implementation, and verified both manually and through the test code that everything is working correctly.
I ran
npm test
to test the code.Types of changes
I would imagine this is just a bug fix, not a breaking change, but I wouldn't know for sure.
Checklist:
I don't think the existing documentation needs to be updated. I expected this to work already based on it.
Note:
It's possibly outside the scope of this ticket, but the output of this error is hard to read when there are zero package directories since JS stringifies an empty array to empty string: