@@ -15,38 +15,36 @@ const GLOB_PACKAGE_JSON = [
1515 "packages/*/*/package.json" ,
1616] ;
1717
18- function update ( path : string ) {
18+ function update ( filename : string ) {
1919 return Effect . gen ( function * ( ) {
2020 const fs = yield * FileSystem . FileSystem ;
21- const packageJsonText = yield * fs . readFileString ( path , "utf8" ) ;
21+ const packageJsonText = yield * fs . readFileString ( filename , "utf8" ) ;
2222 const packageJson = JSON . parse ( packageJsonText ) ;
2323 if ( ! isMatching ( { version : P . string } , packageJson ) ) {
24- yield * Effect . fail ( new Error ( `Invalid package.json at ${ path } : invalid or missing version field` ) ) ;
24+ return yield * Effect . fail ( new Error ( `Invalid package.json at ${ filename } : invalid or missing version field` ) ) ;
2525 }
2626 const newVersion = yield * version ;
2727 const oldVersion = match ( packageJson )
2828 . with ( { version : P . select ( P . string ) } , ( v ) => v )
2929 . otherwise ( ( ) => "0.0.0" ) ;
3030 if ( oldVersion === newVersion ) {
31- yield * Effect . log ( ansis . greenBright ( `Skipping ${ path } as it's already on version ${ newVersion } ` ) ) ;
31+ yield * Effect . log ( ansis . greenBright ( `Skipping ${ filename } as it's already on version ${ newVersion } ` ) ) ;
3232 return false ;
3333 }
3434 const packageJsonUpdated = {
3535 ...packageJson ,
3636 version : newVersion ,
3737 } ;
38- yield * fs . writeFileString ( path , `${ JSON . stringify ( packageJsonUpdated , null , 2 ) } \n` ) ;
39- yield * Effect . log ( `Updated ${ path } to version ${ packageJsonUpdated . version } ` ) ;
38+ yield * fs . writeFileString ( filename , `${ JSON . stringify ( packageJsonUpdated , null , 2 ) } \n` ) ;
39+ yield * Effect . log ( `Updated ${ filename } to version ${ packageJsonUpdated . version } ` ) ;
4040 return true ;
4141 } ) ;
4242}
4343
4444const program = Effect . gen ( function * ( ) {
4545 const ignorePatterns = yield * ignores ;
46- return yield * Effect . all ( glob ( GLOB_PACKAGE_JSON , ignorePatterns ) . map ( update ) , { concurrency : 8 } ) ;
46+ const packageJsonFiles = glob ( GLOB_PACKAGE_JSON , ignorePatterns ) ;
47+ return yield * Effect . all ( packageJsonFiles . map ( update ) , { concurrency : 8 } ) ;
4748} ) ;
4849
49- program . pipe (
50- Effect . provide ( NodeFileSystem . layer ) ,
51- NodeRuntime . runMain ,
52- ) ;
50+ program . pipe ( Effect . provide ( NodeFileSystem . layer ) , NodeRuntime . runMain ) ;
0 commit comments