@@ -51,6 +51,8 @@ function _copy(from: string, to: string) {
51
51
} ) ;
52
52
}
53
53
54
+ const monorepoData = JSON . parse ( fs . readFileSync ( './.monorepo.json' , 'utf-8' ) ) ;
55
+
54
56
function _exec ( command : string , args : string [ ] , opts : { cwd ?: string } ) {
55
57
const { status, error, stdout } = spawnSync ( command , args , {
56
58
stdio : [ 'ignore' , 'pipe' , 'inherit' ] ,
@@ -65,29 +67,27 @@ function _exec(command: string, args: string[], opts: { cwd?: string }) {
65
67
return stdout . toString ( 'utf-8' ) ;
66
68
}
67
69
68
- const monorepoData = JSON . parse ( fs . readFileSync ( './.monorepo.json' , 'utf-8' ) ) ;
69
70
let gitShaCache : string | undefined ;
70
-
71
71
async function _publishSnapshot (
72
72
pkg : PackageInfo ,
73
73
branch : string ,
74
74
message : string ,
75
75
githubToken : string ,
76
76
) {
77
- const monoRepoPackageData = monorepoData [ pkg . name ] ;
78
- if ( ! monoRepoPackageData || ! monorepoData . snapshot ) {
77
+ const snapshotRepo = monorepoData [ pkg . name ] ?. snapshotRepo ;
78
+ if ( ! snapshotRepo ) {
79
79
console . warn ( `Skipping ${ pkg . name } .` ) ;
80
80
81
81
return ;
82
82
}
83
83
84
- console . info ( `Publishing ${ pkg . name } to repo ${ JSON . stringify ( monorepoData . snapshotRepo ) } .` ) ;
84
+ console . info ( `Publishing ${ pkg . name } to repo ${ snapshotRepo } .` ) ;
85
85
86
86
const root = process . cwd ( ) ;
87
87
console . debug ( 'Temporary directory: ' + root ) ;
88
88
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 ) ) ;
91
91
92
92
_exec ( 'git' , [ 'clone' , url ] , { cwd : root } ) ;
93
93
if ( branch ) {
@@ -113,7 +113,7 @@ async function _publishSnapshot(
113
113
114
114
// Add the header to the existing README.md (or create a README if it doesn't exist).
115
115
const readmePath = path . join ( destPath , 'README.md' ) ;
116
- let readme = readmeHeaderFn ( pkg . name , monoRepoPackageData . snapshotRepo ) ;
116
+ let readme = readmeHeaderFn ( pkg . name , snapshotRepo ) ;
117
117
try {
118
118
readme += fs . readFileSync ( readmePath , 'utf-8' ) ;
119
119
} catch { }
0 commit comments