@@ -145,7 +145,7 @@ describe("determineNormalizedModuleContext", () => {
145145} ) ;
146146
147147describe ( "determineModuleContext" , ( ) => {
148- it ( "resolves the correct package name" , ( context ) => {
148+ it ( "resolves the correct unscoped package name" , ( context ) => {
149149 const tempDirectoryPath = setupTempDirectory ( context , {
150150 "package.json" : `{ "name": "root-package" }` ,
151151 // Two sub-packages with the same name
@@ -169,6 +169,31 @@ describe("determineModuleContext", () => {
169169 assert . equal ( relativePath , "some-file.node" ) ;
170170 }
171171 } ) ;
172+
173+ it ( "resolves the correct scoped package name" , ( context ) => {
174+ const tempDirectoryPath = setupTempDirectory ( context , {
175+ "package.json" : `{ "name": "root-package" }` ,
176+ // Two sub-packages with the same name
177+ "sub-package-a/package.json" : `{ "name": "@root-package/my-sub-package-a" }` ,
178+ "sub-package-b/package.json" : `{ "name": "@root-package/my-sub-package-b" }` ,
179+ } ) ;
180+
181+ {
182+ const { packageName, relativePath } = determineModuleContext (
183+ path . join ( tempDirectoryPath , "sub-package-a/some-file.node" )
184+ ) ;
185+ assert . equal ( packageName , "@root-package/my-sub-package-a" ) ;
186+ assert . equal ( relativePath , "some-file.node" ) ;
187+ }
188+
189+ {
190+ const { packageName, relativePath } = determineModuleContext (
191+ path . join ( tempDirectoryPath , "sub-package-b/some-file.node" )
192+ ) ;
193+ assert . equal ( packageName , "@root-package/my-sub-package-b" ) ;
194+ assert . equal ( relativePath , "some-file.node" ) ;
195+ }
196+ } ) ;
172197} ) ;
173198
174199describe ( "getLibraryName" , ( ) => {
0 commit comments