-
Notifications
You must be signed in to change notification settings - Fork 1
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
Documented the case of a scoped package #17
Conversation
2ccb45e
to
7d98af2
Compare
@@ -12,21 +12,22 @@ function normalizeRelativePath(relativePath) { | |||
} | |||
|
|||
function updateFile(oldFile, { filePath, projectName, projectRoot }) { | |||
const regex = new RegExp(`\\b${projectName}/(.*/)*(.*)\\b`, 'g'); | |||
const regex = new RegExp(`(?:'|")(${projectName}/(.*/)*(.*))(?:'|")`, 'g'); |
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.
The word boundary \b
in the beginning led to incorrect matches when the package name is scoped (because projectName
starts with a non-word character @
).
By being more specific about the boundaries (i.e. the file path has to be surrounded by single or double quotation marks), we can also avoid false positives, as evidenced in 0fee1ed.
Thanks for this, @ijlee2 ! It will help a lot for the next addons I'm going to convert :) |
Description
Thanks to @phndiaye's pull request, I realized that the codemod has two bugs:
workspaces
field in the rootpackage.json
should list the package locations, not the package names. A bug would have surfaced when (1) the package is scoped or (2) an end-developer passes the argument--addon-location
,--test-app-location
, or--test-app-name
.References
https://docs.npmjs.com/cli/v7/using-npm/workspaces#defining-workspaces
https://classic.yarnpkg.com/lang/en/docs/workspaces/#toc-tips-tricks
https://pnpm.io/pnpm-workspace_yaml