@@ -66,10 +66,6 @@ describe("resolveNpmDependencies", () => {
6666 const child3_1LicenseContent = "license contents for child3.1" ;
6767 const child3_1LicenseNoticePair : LicenseNoticeKey = `${ child3_1LicenseContent } :` ;
6868
69- const dotDirName = ".dotdir" ;
70- const dotDirVersion = "0.0.0" ;
71- const dotDirRealpath = "/some/path/.dotdir" ;
72-
7369 // A node tree where:
7470 // - child1 is a 'normal' dependency
7571 // - It has two 'normal' dependencies
@@ -166,19 +162,6 @@ describe("resolveNpmDependencies", () => {
166162 peer : true ,
167163 } ,
168164 ] ,
169- [
170- dotDirName ,
171- {
172- pkgid : `${ dotDirName } @${ dotDirVersion } ` ,
173- realpath : dotDirRealpath ,
174- package : { name : dotDirName , version : dotDirVersion } ,
175- name : dotDirName ,
176- children : new Map ( ) ,
177- dev : false ,
178- peer : false ,
179- optional : false ,
180- } ,
181- ] ,
182165 ] ) ,
183166 } as Arborist . Node ;
184167
@@ -475,8 +458,35 @@ describe("resolveNpmDependencies", () => {
475458 } ) ;
476459 } ) ;
477460 describe ( "when a directory inside node_modules starts with '.'" , ( ) => {
461+ const dotDirName = ".dotdir" ;
462+ const dotDirVersion = "0.0.0" ;
463+ const dotDirRealpath = "/some/path/.dotdir" ;
464+
478465 it ( "should skip it without attempting to read its package.json" , async ( ) => {
479466 const licensesMap = new Map < LicenseNoticeKey , ResolvedLicense > ( ) ;
467+
468+ const dotDirNode = {
469+ pkgid : `${ dotDirName } @${ dotDirVersion } ` ,
470+ realpath : dotDirRealpath ,
471+ package : { name : dotDirName , version : dotDirVersion } ,
472+ name : dotDirName ,
473+ children : new Map ( ) ,
474+ dev : false ,
475+ peer : false ,
476+ optional : true ,
477+ } as unknown as Arborist . Node ;
478+
479+ const topNodeWithDotName : Arborist . Node = {
480+ children : new Map ( [
481+ ...Array . from ( topNode . children . entries ( ) ) ,
482+ [ dotDirName , dotDirNode as unknown as Arborist . Node ] ,
483+ ] ) ,
484+ } as Arborist . Node ;
485+
486+ mockedArborist . mockImplementationOnce (
487+ ( ) => ( { loadActual : async ( ) => topNodeWithDotName } ) as Arborist ,
488+ ) ;
489+
480490 await resolveDependenciesForNpmProject ( "/some/path/package.json" , licensesMap ) ;
481491
482492 const keys = Array . from ( licensesMap . keys ( ) ) ;
0 commit comments