File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -133,9 +133,17 @@ function searchPackageVersion(sharedName: string): string | undefined {
133133 path . parse ( potentialPackageJsonDir ) . base !== 'node_modules' &&
134134 potentialPackageJsonDir !== rootDir
135135 ) {
136- const potentialPackageJson = path . join ( potentialPackageJsonDir , 'package.json' ) ;
137- if ( fs . existsSync ( potentialPackageJson ) ) {
138- return require ( potentialPackageJson ) . version ;
136+ const potentialPackageJsonPath = path . join ( potentialPackageJsonDir , 'package.json' ) ;
137+ if ( fs . existsSync ( potentialPackageJsonPath ) ) {
138+ const potentialPackageJson = require ( potentialPackageJsonPath ) ;
139+ if (
140+ typeof potentialPackageJson == 'object' &&
141+ potentialPackageJson !== null &&
142+ typeof potentialPackageJson . version === 'string' &&
143+ potentialPackageJson . name === sharedName
144+ ) {
145+ return potentialPackageJson . version ;
146+ }
139147 }
140148 potentialPackageJsonDir = path . dirname ( potentialPackageJsonDir ) ;
141149 }
You can’t perform that action at this time.
0 commit comments