@@ -35,11 +35,6 @@ async function handleSpecFiles(spec: SpecsToPush, tempGitDir: string): Promise<v
35
35
await run ( `cp ${ toAbsolutePath ( 'docs/versions-history-with-sla-and-support-policy.json' ) } ${ output } ` ) ;
36
36
}
37
37
38
- // adblock extensions ban words like `analytics` so we use a different file name just so the doc dans render it
39
- if ( spec . ext === 'yml' ) {
40
- await run ( `mv ${ output } /analytics.yml ${ output } /searchstats.yml` ) ;
41
- }
42
-
43
38
for ( const client of CLIENTS ) {
44
39
const pathToBundledSpec = toAbsolutePath ( `docs/bundled/${ client } .${ spec . ext } ` ) ;
45
40
@@ -55,12 +50,17 @@ async function handleSpecFiles(spec: SpecsToPush, tempGitDir: string): Promise<v
55
50
let file = await fsp . readFile ( outputFile , 'utf8' ) ;
56
51
57
52
for ( const [ k , v ] of Object . entries ( spec . placeholderVariables ) ) {
58
- file = file . replace ( k , v ) ;
53
+ file = file . replaceAll ( k , v ) ;
59
54
}
60
55
61
56
await fsp . writeFile ( outputFile , file ) ;
62
57
}
63
58
}
59
+
60
+ // adblock extensions ban words like `analytics` so we use a different file name just so the doc dans render it
61
+ if ( spec . ext === 'yml' ) {
62
+ await run ( `mv ${ output } /analytics.yml ${ output } /searchstats.yml` ) ;
63
+ }
64
64
}
65
65
66
66
async function handleGuideFiles ( guide : GuidesToPush , tempGitDir : string ) : Promise < void > {
@@ -130,31 +130,35 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
130
130
await run ( `gh repo clone ${ OWNER } /${ repository } ${ tempGitDir } ` ) ;
131
131
132
132
for ( const task of config . tasks ) {
133
+ console . log ( `Handling '${ task . files . type } ' file(s)` ) ;
134
+
133
135
await run ( `git checkout ${ config . baseBranch } ` , { cwd : tempGitDir } ) ;
134
136
await run ( `git pull origin ${ config . baseBranch } ` , { cwd : tempGitDir } ) ;
135
-
136
- if ( await gitBranchExists ( task . prBranch , tempGitDir ) ) {
137
- await run ( `git fetch origin ${ task . prBranch } ` , { cwd : tempGitDir } ) ;
138
- await run ( `git push -d origin ${ task . prBranch } ` , { cwd : tempGitDir } ) ;
139
- }
140
137
await run ( `git checkout -B ${ task . prBranch } ` , { cwd : tempGitDir } ) ;
141
138
142
- console . log ( `Handling '${ task . files . type } ' file(s)` ) ;
143
-
144
139
if ( task . files . type === 'specs' ) {
145
140
await handleSpecFiles ( task . files , tempGitDir ) ;
146
141
} else {
147
142
await handleGuideFiles ( task . files , tempGitDir ) ;
148
143
}
149
144
145
+ if ( process . env . DRYRUN ) {
146
+ console . log ( `asked for a dry run, stopping before push and PR for '${ repository } ' on task '${ task . prBranch } '` ) ;
147
+
148
+ continue ;
149
+ }
150
+
151
+ if ( await gitBranchExists ( task . prBranch , tempGitDir ) ) {
152
+ await run ( `git fetch origin ${ task . prBranch } ` , { cwd : tempGitDir } ) ;
153
+ await run ( `git push -d origin ${ task . prBranch } ` , { cwd : tempGitDir } ) ;
154
+ }
155
+
150
156
if ( ( await getNbGitDiff ( { head : null , cwd : tempGitDir } ) ) === 0 ) {
151
157
console . log ( `❎ Skipping push to ${ OWNER } /${ repository } because there is no change.` ) ;
152
158
153
159
continue ;
154
160
}
155
161
156
- console . log ( `Pushing to '${ task . prBranch } ` ) ;
157
-
158
162
await configureGitHubAuthor ( tempGitDir ) ;
159
163
160
164
await run ( 'git add .' , { cwd : tempGitDir } ) ;
@@ -164,12 +168,6 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
164
168
cwd : tempGitDir ,
165
169
} ) ;
166
170
167
- if ( process . env . DRYRUN ) {
168
- console . log ( `asked for a dry run, stopping before push and PR for '${ repository } ' on task '${ task . prBranch } '` ) ;
169
-
170
- continue ;
171
- }
172
-
173
171
await run ( `git push -f -u origin ${ task . prBranch } ` , { cwd : tempGitDir } ) ;
174
172
175
173
console . log ( `Creating pull request on ${ OWNER } /${ repository } ...` ) ;
0 commit comments