-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug/issue 1349 handle false positive package.json files in packages w…
…hen running walker package ranger (#1356)
- Loading branch information
1 parent
bda129f
commit 95d8613
Showing
5 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ function resolveBareSpecifier(specifier) { | |
* { | ||
* dependencyName: 'lit-html', | ||
* resolved: 'file:///path/to/project/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/lit-html/node/lit-html.js', | ||
* root: 'file:///path/to/project/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/lit-html/package.json' | ||
* root: 'file:///path/to/project/greenwood-lit-ssr/node_modules/.pnpm/[email protected]/node_modules/lit-html/ | ||
* } | ||
*/ | ||
function derivePackageRoot(resolved) { | ||
|
@@ -52,7 +52,15 @@ function derivePackageRoot(resolved) { | |
|
||
for (const segment of segments.slice(1)) { | ||
if (fs.existsSync(new URL('./package.json', root))) { | ||
break; | ||
// we have to check that this package.json actually has as a name AND version | ||
// https://github.com/moment/luxon/issues/1543#issuecomment-2546858540 | ||
// https://github.com/ProjectEvergreen/greenwood/issues/1349 | ||
const resolvedPackageJson = JSON.parse(fs.readFileSync(new URL('./package.json', root), 'utf-8')); | ||
const { name, version } = resolvedPackageJson; | ||
|
||
if (name && version) { | ||
break; | ||
} | ||
} | ||
|
||
root = root.replace(`${segment}/`, ''); | ||
|
This file contains 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
This file contains 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
This file contains 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