File tree 2 files changed +32
-6
lines changed
2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,13 @@ export class Job {
174
174
return new Promise < any > ( ( resolve , reject ) => {
175
175
const jobNameStr = this . getJobNameString ( ) ;
176
176
const outputFilesPath = this . getOutputFilesPath ( ) ;
177
+
178
+ const split = script . split ( " && " ) ;
179
+ split . forEach ( ( s ) => {
180
+ console . log ( `${ jobNameStr } ${ c . green ( `\$ ${ s } ` ) } ` ) ;
181
+ fs . appendFileSync ( outputFilesPath , `\$ ${ s } \n` ) ;
182
+ } ) ;
183
+
177
184
const child = shelljs . exec ( `${ script } ` , {
178
185
cwd : this . cwd ,
179
186
env : this . getEnvs ( ) ,
@@ -188,12 +195,26 @@ export class Job {
188
195
189
196
if ( child . stdout ) {
190
197
child . stdout . on ( "data" , ( buf ) => {
198
+ const lines = `${ buf } ` . split ( / \r ? \n / ) ;
199
+ lines . forEach ( ( l ) => {
200
+ if ( ! l ) {
201
+ return ;
202
+ }
203
+ process . stdout . write ( `${ jobNameStr } ${ c . greenBright ( ">" ) } ${ l } \n` ) ;
204
+ } ) ;
191
205
fs . appendFileSync ( outputFilesPath , `${ buf } ` ) ;
192
206
} ) ;
193
207
}
194
208
if ( child . stderr ) {
195
209
child . stderr . on ( "data" , ( buf ) => {
196
- fs . appendFileSync ( outputFilesPath , `${ c . red ( `${ buf } ` ) } ` ) ;
210
+ const lines = `${ buf } ` . split ( / \r ? \n / ) ;
211
+ lines . forEach ( ( l ) => {
212
+ if ( ! l ) {
213
+ return ;
214
+ }
215
+ process . stderr . write ( `${ jobNameStr } ${ c . redBright ( ">" ) } ${ l } \n` ) ;
216
+ } ) ;
217
+ fs . appendFileSync ( outputFilesPath , `${ buf } ` ) ;
197
218
} ) ;
198
219
}
199
220
Original file line number Diff line number Diff line change @@ -33,16 +33,21 @@ export class Parser {
33
33
const orderedYml = [ ] ;
34
34
35
35
// Add .gitlab-ci.yml
36
- orderedYml . push ( Parser . loadYaml ( `${ cwd } /.gitlab-ci.yml` ) ) ;
37
- if ( ! orderedYml . last ( ) ) { // Fail if empty
38
- console . error ( `${ cwd } /.gitlab-ci.yml is empty ` ) ;
36
+ let path = `${ cwd } /.gitlab-ci.yml` ;
37
+ if ( ! fs . existsSync ( path ) ) { // Fail if empty
38
+ console . error ( `${ cwd } /.gitlab-ci.yml is not found ` ) ;
39
39
process . exit ( 1 ) ;
40
40
}
41
+ orderedYml . push ( Parser . loadYaml ( `${ cwd } /.gitlab-ci.yml` ) ) ;
41
42
orderedVariables . push ( orderedYml . last ( ) . variables ) ;
42
43
43
- // Add .gitlab-ci.yml
44
- orderedYml . push ( Parser . loadYaml ( `${ cwd } /.gitlab-ci-local.yml` ) ) ;
44
+ // Add .gitlab-ci-local.yml
45
+ path = `${ cwd } /.gitlab-ci-local.yml` ;
46
+ orderedYml . push ( Parser . loadYaml ( path ) ) ;
45
47
orderedVariables . push ( orderedYml . last ( ) . variables || { } ) ;
48
+ if ( ! orderedYml . last ( ) || Object . keys ( orderedYml . last ( ) ) . length === 0 ) { // Warn if empty
49
+ console . error ( `WARN: ${ cwd } /.gitlab-ci-local.yml is empty or not found` ) ;
50
+ }
46
51
47
52
// Add included yaml's.
48
53
orderedYml . unshift ( { } ) ;
You can’t perform that action at this time.
0 commit comments