Repository navigation
fix(exec): set MELOS_PARENT_PACKAGE_* for example packages - #1123
Merged
Merged
Conversation
`Package.isExample` checked the directory above the package, so for `my_package/example` it was false and `melos exec` never set the parent package variables. It now checks the package's own directory, which is what `exec` assumes when it reads `../pubspec.yaml`.
|
To preview the documentation for this pull request, visit the following URL:
|
With the directory check alone, a top-level `example` package got the workspace root as its parent. The parent must now be a workspace package, as it was before 7.0.0, and its name, version and path come from that package instead of re-parsing its pubspec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Since 7.0.0 (#834),
melos exechasn't setMELOS_PARENT_PACKAGE_NAME,_VERSIONand_PATHfor an example package such asmy_package/example.Package.isExamplestarted checking the directory above the package (my_package) rather than the package's own directory.The fix:
isExamplenow checks the package's own directory name again.execsets the variables only when the directory above is a workspace package, as before 7.0.0, and takes the values from that package. The environment variable docs now say "directory" instead of "package name".Behaviour changes, back to the pre-7.0.0 behaviour:
example/app, no longer gets theexamplefolder's package as its parent.examplepackage never gets the workspace root as its parent.Tests
exec_test.dart, "exec sets the parent package variables for an example package":melos execruns a Dart script that prints the variables ina,a/example,a/example/appand a top-levelexample. Onlya/exampleshould getaas its parent. Without the fix,a/examplegets nothing anda/example/appgetsa_example.Type of Change
feat-- New feature (non-breaking change which adds functionality)fix-- Bug fix (non-breaking change which fixes an issue)!-- Breaking change (fix or feature that would cause existing functionality to change)refactor-- Code refactorci-- Build configuration changedocs-- Documentationchore-- Chore