@@ -43,7 +43,7 @@ const getAllPackageJsons = async (workspaces, cwd) => {
4343 workspaceGlobs . map (
4444 ( workspace ) =>
4545 new Promise ( ( resolve , reject ) => {
46- glob ( `${ workspace } /${ PACKAGE_JSON } ` , { cwd} , ( error , files ) => {
46+ glob ( `${ workspace } /${ PACKAGE_JSON } ` , { cwd } , ( error , files ) => {
4747 if ( error ) {
4848 reject ( error ) ;
4949 }
@@ -103,7 +103,7 @@ const getPackageNamesAndPackageDir = (packageFilePaths, cwd) =>
103103 packageFilePaths . reduce ( ( map , packageFilePath ) => {
104104 const fullPackageFilePath = path . join ( cwd , packageFilePath ) ;
105105 const packageJson = require ( fullPackageFilePath ) ;
106- const { name} = packageJson ;
106+ const { name } = packageJson ;
107107 map . set ( name , {
108108 packageDir : path . dirname ( fullPackageFilePath ) ,
109109 hasTsEntry : / \. ( t s | t s x ) $ / . test ( ( packageJson . main ? packageJson . main : '' ) )
@@ -113,7 +113,7 @@ const getPackageNamesAndPackageDir = (packageFilePaths, cwd) =>
113113
114114const getReferencesFromDependencies = (
115115 configName ,
116- { packageDir} ,
116+ { packageDir } ,
117117 packageName ,
118118 packagesMap ,
119119 verbose
@@ -142,7 +142,7 @@ const getReferencesFromDependencies = (
142142 return Object . keys ( mergedDependencies )
143143 . reduce ( ( referenceArray , dependency ) => {
144144 if ( packagesMap . has ( dependency ) ) {
145- const { packageDir : dependencyDir } = packagesMap . get ( dependency ) ;
145+ const { packageDir : dependencyDir } = packagesMap . get ( dependency ) ;
146146 const relativePath = path . relative ( packageDir , dependencyDir ) ;
147147 const detectedConfig = detectTSConfig ( dependencyDir , configName )
148148 if ( detectedConfig !== null ) {
@@ -174,7 +174,7 @@ const updateTsConfig = (
174174 paths ,
175175 check ,
176176 createPathMappings = false ,
177- { packageDir} = { packageDir : process . cwd ( ) } ,
177+ { packageDir } = { packageDir : process . cwd ( ) } ,
178178) => {
179179 const tsconfigFilePath = path . join ( packageDir , configName ) ;
180180
@@ -183,7 +183,7 @@ const updateTsConfig = (
183183
184184 const currentReferences = config . references || [ ] ;
185185
186- const mergedReferences = references . map ( ( { path} ) => ( {
186+ const mergedReferences = references . map ( ( { path } ) => ( {
187187 path,
188188 ...currentReferences . find ( ( currentRef ) => currentRef . path === path ) ,
189189 } ) ) ;
@@ -205,13 +205,13 @@ const updateTsConfig = (
205205 assign ( compilerOptions ,
206206 paths && Object . keys ( paths ) . length > 0 ? {
207207 paths
208- } : { paths : undefined } )
208+ } : { paths : undefined } )
209209
210210 const newTsConfig = assign ( config ,
211- {
211+ Object . keys ( compilerOptions ) . length > 0 ? {
212212 compilerOptions,
213213 references : mergedReferences . length ? mergedReferences : undefined ,
214- }
214+ } : { references : mergedReferences . length ? mergedReferences : undefined , }
215215 ) ;
216216 fs . writeFileSync ( tsconfigFilePath , stringify ( newTsConfig , null , 2 ) + '\n' ) ;
217217 }
@@ -220,30 +220,31 @@ const updateTsConfig = (
220220 return 0 ;
221221 } catch ( error ) {
222222 console . error ( `could not read ${ tsconfigFilePath } ` , error ) ;
223- if ( strict )
223+ if ( strict )
224224 throw new Error ( 'Expect always a tsconfig.json in the package directory while running in strict mode' )
225225 }
226226} ;
227227
228228function getPathsFromReferences ( references , tsconfigMap , ignorePathMappings
229- = [ ] ) {
229+ = [ ] ) {
230230 return references . reduce ( ( paths , ref ) => {
231- if ( ignorePathMappings . includes ( ref . name ) ) return paths
232- const rootFolder = tsconfigMap [ ref . name ] ?. compilerOptions ?. rootDir ?? 'src'
231+ if ( ignorePathMappings . includes ( ref . name ) ) return paths
232+ const rootFolder = tsconfigMap [ ref . name ] ?. compilerOptions ?. rootDir ?? 'src'
233233 return {
234- ...paths ,
235- [ `${ ref . name } ` ] : [ `${ ref . folder } ${ rootFolder === '.' ? '' : `/${ rootFolder } ` } ` ] ,
236- } } , { } ) ;
234+ ...paths ,
235+ [ `${ ref . name } ` ] : [ `${ ref . folder } ${ rootFolder === '.' ? '' : `/${ rootFolder } ` } ` ] ,
236+ }
237+ } , { } ) ;
237238}
238239
239240const execute = async ( {
240- cwd, createTsConfig,
241- verbose,
242- check,
243- usecase,
244- strict,
245- ...configurable
246- } ) => {
241+ cwd, createTsConfig,
242+ verbose,
243+ check,
244+ usecase,
245+ strict,
246+ ...configurable
247+ } ) => {
247248 let changesCount = 0 ;
248249 // eslint-disable-next-line no-console
249250 console . log ( 'updating tsconfigs' ) ;
@@ -273,7 +274,7 @@ const execute = async ({
273274 withoutRootConfig
274275 } = configurable
275276
276- let ignorePathMappings = [ ]
277+ let ignorePathMappings = [ ]
277278
278279 if ( fs . existsSync ( path . join ( cwd , usecase ) ) ) {
279280 const yamlConfig = yaml . load (
@@ -292,7 +293,7 @@ const execute = async ({
292293 console . log ( `createPathMappings ${ createPathMappings } ` )
293294 console . log ( 'joined workspaces' , workspaces ) ;
294295 console . log ( 'ignorePathMappings' , ignorePathMappings
295- ) ;
296+ ) ;
296297 }
297298 }
298299
@@ -382,13 +383,13 @@ const execute = async ({
382383 console . log ( 'rootReferences' , rootReferences ) ;
383384 console . log ( 'rootPaths' , rootPaths ) ;
384385 }
385- if ( withoutRootConfig === false ) {
386+ if ( withoutRootConfig === false ) {
386387 changesCount += updateTsConfig (
387388 strict ,
388389 rootConfigName ,
389390 rootReferences ,
390391 rootPaths ,
391- check , createPathMappings , { packageDir : cwd } ,
392+ check , createPathMappings , { packageDir : cwd } ,
392393 ) ;
393394 }
394395
@@ -398,4 +399,4 @@ const execute = async ({
398399 return changesCount ;
399400} ;
400401
401- module . exports = { execute, defaultOptions} ;
402+ module . exports = { execute, defaultOptions } ;
0 commit comments