@@ -37,21 +37,29 @@ function init(token, apiUrl) {
3737 } ) ;
3838}
3939
40+ function arrayIsArray ( array ) {
41+ return ! ! array && Array . isArray ( array ) ;
42+ }
43+
4044function arrayHasElements ( array ) {
41- return array && Array . isArray ( array ) && array . length > 0 ;
45+ return arrayIsArray ( array ) && array . length > 0 ;
4246}
4347
44- function extractChangedOrDeletedFiles ( changedFiles , deletedFiles ) {
48+ function checkChangedOrDeletedFiles ( changedFiles , deletedFiles ) {
4549 const changedFilesExist = arrayHasElements ( changedFiles ) ;
4650 const deletedFilesExist = arrayHasElements ( deletedFiles ) ;
4751
4852 if ( ! changedFilesExist && ! deletedFilesExist ) {
4953 throw new Error ( "No files specified as changed or deleted. Quitting." ) ;
5054 }
5155
56+ return true ;
57+ }
58+
59+ function extractChangedOrDeletedFiles ( changedFiles , deletedFiles ) {
5260 return {
53- changedFiles : changedFilesExist ? changedFiles : [ ] ,
54- deletedFiles : deletedFilesExist ? deletedFiles : [ ] ,
61+ changedFiles : arrayIsArray ( changedFiles ) ? changedFiles : [ ] ,
62+ deletedFiles : arrayIsArray ( deletedFiles ) ? deletedFiles : [ ] ,
5563 } ;
5664}
5765
@@ -181,6 +189,7 @@ async function createCommitOnBranch(
181189
182190module . exports = {
183191 init,
192+ checkChangedOrDeletedFiles,
184193 extractChangedOrDeletedFiles,
185194 createCommitOnBranch,
186195 checkIfBranchExists,
0 commit comments