@@ -59,25 +59,40 @@ module.exports = require("os");
59
59
const core = __webpack_require__ ( 470 ) ;
60
60
const { promises : fs } = __webpack_require__ ( 747 ) ;
61
61
62
- const main = async ( ) => {
63
- const filePaths = JSON . parse ( core . getInput ( 'files' ) ) ;
64
- console . log ( filePaths ) ;
65
- var output = "" ;
62
+ const main = ( ) => {
63
+ const filePaths = JSON . parse ( core . getInput ( "files" ) ) ;
64
+ const regularExpression = core . getInput ( "pattern" ) ;
66
65
67
- filePaths . forEach ( async ( filePath ) => {
66
+ const pattern = new RegExp ( regularExpression ) ;
68
67
69
- if ( filePath . includes ( "migrations" ) ) {
70
- output += `========================== ${ filePath } ==========================\n\n` ;
71
- const content = await fs . readFile ( process . env . GITHUB_WORKSPACE + "/" + filePath , 'utf8' ) ;
72
- output += content + "\n\n" ;
68
+ console . log ( filePaths , pattern ) ;
73
69
74
- }
70
+ const matchingFilePaths = filePaths
71
+ . filter ( ( filePath ) => pattern . test ( filePath ) ) ;
75
72
76
- } ) ;
77
- core . setOutput ( 'content' , output ) ;
78
- }
73
+ return Promise . all ( [
74
+ Promise . resolve ( matchingFilePaths ) ,
75
+ ...matchingFilePaths . map ( ( filePath ) => fs . readFile ( process . env . GITHUB_WORKSPACE + "/" + filePath , "utf8" ) )
76
+ ] ) ;
77
+
78
+ } ;
79
+
80
+ main ( )
81
+ . then ( ( response ) => {
82
+
83
+ const [ matchingFilePaths , ...fileContents ] = response ;
84
+
85
+ let output = '' ;
86
+
87
+ fileContents . forEach ( ( content , index ) => {
88
+ output += `========================== ${ matchingFilePaths [ index ] } ==========================\n\n` ;
89
+ output += content + "\n\n" ;
90
+ } )
91
+
92
+ core . setOutput ( "content" , output ) ;
79
93
80
- main ( ) . catch ( err => core . setFailed ( err . message ) ) ;
94
+ } )
95
+ . catch ( ( err ) => core . setFailed ( err . message ) ) ;
81
96
82
97
83
98
/***/ } ) ,
0 commit comments