@@ -7,7 +7,7 @@ import { assert } from "tsafe/assert";
77import { exclude } from "tsafe/exclude" ;
88import { writeFile , readFile , rm } from "fs/promises" ;
99import { crawl } from "./tools/crawl" ;
10- import { basename as pathBasename } from "path" ;
10+ import { basename as pathBasename , sep as pathSep } from "path" ;
1111import type { Equals } from "tsafe" ;
1212
1313export const pathOfIconsJson = pathJoin ( "utility" , "icons" , "icons.json" ) ;
@@ -109,14 +109,60 @@ async function main() {
109109 const candidateFilePaths = (
110110 await crawl ( {
111111 "dirPath" : cwd ,
112- "getDoCrawlInDir" : ( { relativeDirPath } ) => {
113- const dirBasename = pathBasename ( relativeDirPath ) ;
112+ "getDoCrawlInDir" : async ( { relativeDirPath } ) => {
113+ if ( relativeDirPath === "node_modules" ) {
114+ return true ;
115+ }
116+
117+ if (
118+ relativeDirPath . startsWith ( `node_modules${ pathSep } @` ) &&
119+ relativeDirPath . split ( pathSep ) . length === 2
120+ ) {
121+ return true ;
122+ }
123+
124+ if (
125+ relativeDirPath . startsWith ( "node_modules" ) &&
126+ ( relativeDirPath . split ( pathSep ) . length === 2 ||
127+ ( relativeDirPath . startsWith ( `node_modules${ pathSep } @` ) &&
128+ relativeDirPath . split ( pathSep ) . length === 3 ) )
129+ ) {
130+ const parsedPackageJson = await readFile (
131+ pathJoin ( relativeDirPath , "package.json" )
132+ ) . then (
133+ buff => JSON . parse ( buff . toString ( "utf8" ) ) ,
134+ ( ) => undefined
135+ ) ;
136+
137+ if ( parsedPackageJson === undefined ) {
138+ return false ;
139+ }
140+
141+ if (
142+ Object . keys ( {
143+ ...parsedPackageJson [ "dependencies" ] ,
144+ ...parsedPackageJson [ "devDependencies" ]
145+ } ) . includes ( "@gouvfr/dsfr" )
146+ ) {
147+ return true ;
148+ }
149+
150+ return false ;
151+ }
152+
153+ if ( relativeDirPath === `public${ pathSep } dsfr` ) {
154+ return false ;
155+ }
156+
157+ if ( pathBasename ( relativeDirPath ) === "generatedFromCss" ) {
158+ return false ;
159+ }
114160
115- if ( dirBasename === "node_modules" ) {
161+ if ( pathBasename ( relativeDirPath ) === "node_modules" ) {
116162 return false ;
117163 }
118164
119- if ( dirBasename . startsWith ( "." ) ) {
165+ if ( pathBasename ( relativeDirPath ) . startsWith ( "." ) ) {
120166 return false ;
121167 }
122168
0 commit comments