@@ -51,6 +51,8 @@ function _copy(from: string, to: string) {
5151 } ) ;
5252}
5353
54+ const monorepoData = JSON . parse ( fs . readFileSync ( './.monorepo.json' , 'utf-8' ) ) ;
55+
5456function _exec ( command : string , args : string [ ] , opts : { cwd ?: string } ) {
5557 const { status, error, stdout } = spawnSync ( command , args , {
5658 stdio : [ 'ignore' , 'pipe' , 'inherit' ] ,
@@ -65,29 +67,27 @@ function _exec(command: string, args: string[], opts: { cwd?: string }) {
6567 return stdout . toString ( 'utf-8' ) ;
6668}
6769
68- const monorepoData = JSON . parse ( fs . readFileSync ( './.monorepo.json' , 'utf-8' ) ) ;
6970let gitShaCache : string | undefined ;
70-
7171async function _publishSnapshot (
7272 pkg : PackageInfo ,
7373 branch : string ,
7474 message : string ,
7575 githubToken : string ,
7676) {
77- const monoRepoPackageData = monorepoData [ pkg . name ] ;
78- if ( ! monoRepoPackageData || ! monorepoData . snapshot ) {
77+ const snapshotRepo = monorepoData [ pkg . name ] ?. snapshotRepo ;
78+ if ( ! snapshotRepo ) {
7979 console . warn ( `Skipping ${ pkg . name } .` ) ;
8080
8181 return ;
8282 }
8383
84- console . info ( `Publishing ${ pkg . name } to repo ${ JSON . stringify ( monorepoData . snapshotRepo ) } .` ) ;
84+ console . info ( `Publishing ${ pkg . name } to repo ${ snapshotRepo } .` ) ;
8585
8686 const root = process . cwd ( ) ;
8787 console . debug ( 'Temporary directory: ' + root ) ;
8888
89- const url = `https://${ githubToken ? githubToken + '@' : '' } github.com/${ monorepoData . snapshotRepo } .git` ;
90- const destPath = path . join ( root , path . basename ( monorepoData . snapshotRepo ) ) ;
89+ const url = `https://${ githubToken ? githubToken + '@' : '' } github.com/${ snapshotRepo } .git` ;
90+ const destPath = path . join ( root , path . basename ( snapshotRepo ) ) ;
9191
9292 _exec ( 'git' , [ 'clone' , url ] , { cwd : root } ) ;
9393 if ( branch ) {
@@ -113,7 +113,7 @@ async function _publishSnapshot(
113113
114114 // Add the header to the existing README.md (or create a README if it doesn't exist).
115115 const readmePath = path . join ( destPath , 'README.md' ) ;
116- let readme = readmeHeaderFn ( pkg . name , monoRepoPackageData . snapshotRepo ) ;
116+ let readme = readmeHeaderFn ( pkg . name , snapshotRepo ) ;
117117 try {
118118 readme += fs . readFileSync ( readmePath , 'utf-8' ) ;
119119 } catch { }
0 commit comments