@@ -167,7 +167,7 @@ describe("determineNormalizedModuleContext", () => {
167167} ) ;
168168
169169describe ( "determineModuleContext" , ( ) => {
170- it ( "resolves the correct package name" , ( context ) => {
170+ it ( "resolves the correct unscoped package name" , ( context ) => {
171171 const tempDirectoryPath = setupTempDirectory ( context , {
172172 "package.json" : `{ "name": "root-package" }` ,
173173 // Two sub-packages with the same name
@@ -191,6 +191,31 @@ describe("determineModuleContext", () => {
191191 assert . equal ( relativePath , "some-file.node" ) ;
192192 }
193193 } ) ;
194+
195+ it ( "resolves the correct scoped package name" , ( context ) => {
196+ const tempDirectoryPath = setupTempDirectory ( context , {
197+ "package.json" : `{ "name": "root-package" }` ,
198+ // Two sub-packages with the same name
199+ "sub-package-a/package.json" : `{ "name": "@root-package/my-sub-package-a" }` ,
200+ "sub-package-b/package.json" : `{ "name": "@root-package/my-sub-package-b" }` ,
201+ } ) ;
202+
203+ {
204+ const { packageName, relativePath } = determineModuleContext (
205+ path . join ( tempDirectoryPath , "sub-package-a/some-file.node" )
206+ ) ;
207+ assert . equal ( packageName , "@root-package/my-sub-package-a" ) ;
208+ assert . equal ( relativePath , "some-file.node" ) ;
209+ }
210+
211+ {
212+ const { packageName, relativePath } = determineModuleContext (
213+ path . join ( tempDirectoryPath , "sub-package-b/some-file.node" )
214+ ) ;
215+ assert . equal ( packageName , "@root-package/my-sub-package-b" ) ;
216+ assert . equal ( relativePath , "some-file.node" ) ;
217+ }
218+ } ) ;
194219} ) ;
195220
196221describe ( "getLibraryName" , ( ) => {
0 commit comments