@@ -82,7 +82,7 @@ module.exports = function (octokit, opts) {
82
82
if ( ! baseTree || forkFromBaseBranch ) {
83
83
if ( ! createBranch && ! baseTree ) {
84
84
return reject (
85
- `The branch '${ branchName } ' doesn't exist and createBranch is 'false'` ,
85
+ `The branch '${ branchName } ' doesn't exist and createBranch is 'false'`
86
86
) ;
87
87
}
88
88
@@ -125,7 +125,7 @@ module.exports = function (octokit, opts) {
125
125
126
126
if ( ! hasFiles && ! hasFilesToDelete ) {
127
127
return reject (
128
- `either changes[].files or changes[].filesToDelete are required` ,
128
+ `either changes[].files or changes[].filesToDelete are required`
129
129
) ;
130
130
}
131
131
@@ -140,14 +140,14 @@ module.exports = function (octokit, opts) {
140
140
owner ,
141
141
repo ,
142
142
fileName ,
143
- baseTree ,
143
+ baseTree
144
144
) ;
145
145
146
146
// If it doesn't exist, and we're not ignoring missing files
147
147
// reject the promise
148
148
if ( ! exists && ! change . ignoreDeletionFailures ) {
149
149
return reject (
150
- `The file ${ fileName } could not be found in the repo` ,
150
+ `The file ${ fileName } could not be found in the repo`
151
151
) ;
152
152
}
153
153
@@ -160,40 +160,42 @@ module.exports = function (octokit, opts) {
160
160
type : "commit" ,
161
161
} ) ;
162
162
}
163
- } ) ,
163
+ } )
164
164
) ;
165
165
}
166
166
}
167
167
168
- for ( const batch of chunk ( Object . keys ( change . files ) , batchSize ) ) {
169
- await Promise . all (
170
- batch . map ( async ( fileName ) => {
171
- const properties = change . files [ fileName ] || "" ;
172
-
173
- const contents = properties . contents || properties ;
174
- const mode = properties . mode || "100644" ;
175
- const type = properties . type || "blob" ;
176
-
177
- if ( ! contents ) {
178
- return reject ( `No file contents provided for ${ fileName } ` ) ;
179
- }
180
-
181
- const fileSha = await createBlob (
182
- octokit ,
183
- owner ,
184
- repo ,
185
- contents ,
186
- type ,
187
- ) ;
188
-
189
- treeItems . push ( {
190
- path : fileName ,
191
- sha : fileSha ,
192
- mode : mode ,
193
- type : type ,
194
- } ) ;
195
- } ) ,
196
- ) ;
168
+ if ( hasFiles ) {
169
+ for ( const batch of chunk ( Object . keys ( change . files ) , batchSize ) ) {
170
+ await Promise . all (
171
+ batch . map ( async ( fileName ) => {
172
+ const properties = change . files [ fileName ] || "" ;
173
+
174
+ const contents = properties . contents || properties ;
175
+ const mode = properties . mode || "100644" ;
176
+ const type = properties . type || "blob" ;
177
+
178
+ if ( ! contents ) {
179
+ return reject ( `No file contents provided for ${ fileName } ` ) ;
180
+ }
181
+
182
+ const fileSha = await createBlob (
183
+ octokit ,
184
+ owner ,
185
+ repo ,
186
+ contents ,
187
+ type
188
+ ) ;
189
+
190
+ treeItems . push ( {
191
+ path : fileName ,
192
+ sha : fileSha ,
193
+ mode : mode ,
194
+ type : type ,
195
+ } ) ;
196
+ } )
197
+ ) ;
198
+ }
197
199
}
198
200
199
201
// no need to issue further requests if there are no updates, creations and deletions
@@ -207,7 +209,7 @@ module.exports = function (octokit, opts) {
207
209
owner ,
208
210
repo ,
209
211
treeItems ,
210
- baseTree ,
212
+ baseTree
211
213
) ;
212
214
213
215
// Create a commit that points to that tree
@@ -219,7 +221,7 @@ module.exports = function (octokit, opts) {
219
221
author ,
220
222
message ,
221
223
tree ,
222
- baseTree ,
224
+ baseTree
223
225
) ;
224
226
225
227
// Update the base tree if we have another commit to make
@@ -277,7 +279,7 @@ async function createCommit(
277
279
author ,
278
280
message ,
279
281
tree ,
280
- baseTree ,
282
+ baseTree
281
283
) {
282
284
return (
283
285
await octokit . rest . git . createCommit ( {
0 commit comments