@@ -13,6 +13,17 @@ const REPO_ROOT = path.resolve(__dirname, '..');
1313const NPM_EXEC_PATH = process . env . npm_execpath || '' ;
1414const VERIFY_PREFIX = '[release:verify]' ;
1515
16+ function nodeModulesDirForPackageName ( packageName ) {
17+ if ( packageName . startsWith ( '@' ) ) {
18+ const [ scope , name ] = packageName . split ( '/' ) ;
19+ if ( ! scope || ! name ) {
20+ throw new Error ( `Invalid scoped package name: ${ packageName } ` ) ;
21+ }
22+ return path . join ( 'node_modules' , scope , name ) ;
23+ }
24+ return path . join ( 'node_modules' , packageName ) ;
25+ }
26+
1627function log ( message ) {
1728 // eslint-disable-next-line no-console
1829 console . log ( `${ VERIFY_PREFIX } ${ message } ` ) ;
@@ -198,7 +209,11 @@ async function main() {
198209 await runNpm ( [ 'init' , '-y' ] , { cwd : tempDir , stdio : 'ignore' } ) ;
199210 await runNpm ( [ 'install' , tarballPath , '--silent' ] , { cwd : tempDir } ) ;
200211
201- const installedPkgPath = path . join ( tempDir , 'node_modules' , 'secbot' , 'package.json' ) ;
212+ const rootPkg = parseJsonText (
213+ await fsp . readFile ( path . join ( REPO_ROOT , 'package.json' ) , 'utf8' ) ,
214+ 'Failed to read root package.json' ,
215+ ) ;
216+ const installedPkgPath = path . join ( tempDir , nodeModulesDirForPackageName ( rootPkg . name ) , 'package.json' ) ;
202217 if ( ! fs . existsSync ( installedPkgPath ) ) {
203218 throw new Error ( 'Installed package.json not found' ) ;
204219 }
0 commit comments