@@ -13,35 +13,24 @@ import {Utils} from "./utils.js";
13
13
import { Argv } from "./argv.js" ;
14
14
import assert from "assert" ;
15
15
16
- const generateGitIgnore = ( cwd : string , stateDir : string ) => {
17
- const gitIgnoreFilePath = `${ cwd } /${ stateDir } /.gitignore` ;
18
- const gitIgnoreContent = "*\n!.gitignore\n" ;
19
- if ( ! fs . existsSync ( gitIgnoreFilePath ) ) {
20
- fs . outputFileSync ( gitIgnoreFilePath , gitIgnoreContent ) ;
21
- }
22
- } ;
23
-
24
16
export async function handler ( args : any , writeStreams : WriteStreams , jobs : Job [ ] = [ ] ) {
25
17
const argv = await Argv . build ( args , writeStreams ) ;
26
18
const cwd = argv . cwd ;
27
19
const stateDir = argv . stateDir ;
28
- const file = argv . file ;
29
20
let parser : Parser | null = null ;
30
21
31
22
if ( argv . completion ) {
32
23
yargs ( process . argv . slice ( 2 ) ) . showCompletionScript ( ) ;
33
24
return [ ] ;
34
25
}
35
26
36
- assert ( fs . existsSync ( `${ cwd } /${ file } ` ) , `${ path . resolve ( cwd ) } /${ file } could not be found` ) ;
37
-
38
27
if ( argv . fetchIncludes ) {
39
28
await Parser . create ( argv , writeStreams , 0 , jobs ) ;
40
29
return [ ] ;
41
30
}
42
31
43
32
if ( argv . preview ) {
44
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
33
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
45
34
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs , false ) ;
46
35
const gitlabData = parser . gitlabData ;
47
36
for ( const jobName of Object . keys ( gitlabData ) ) {
@@ -55,46 +44,43 @@ export async function handler (args: any, writeStreams: WriteStreams, jobs: Job[
55
44
}
56
45
writeStreams . stdout ( `---\n${ yaml . dump ( gitlabData , { lineWidth : 160 } ) } ` ) ;
57
46
} else if ( argv . list || argv . listAll ) {
58
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
47
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
59
48
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs ) ;
60
49
Commander . runList ( parser , writeStreams , argv . listAll ) ;
61
50
} else if ( argv . listJson ) {
62
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
51
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
63
52
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs ) ;
64
53
Commander . runJson ( parser , writeStreams ) ;
65
54
} else if ( argv . listCsv || argv . listCsvAll ) {
66
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
55
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
67
56
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs ) ;
68
57
Commander . runCsv ( parser , writeStreams , argv . listCsvAll ) ;
69
58
} else if ( argv . job . length > 0 ) {
70
59
assert ( argv . stage === null , "You cannot use --stage when starting individual jobs" ) ;
71
- generateGitIgnore ( cwd , stateDir ) ;
72
60
const time = process . hrtime ( ) ;
73
61
if ( argv . needs || argv . onlyNeeds ) {
74
- await fs . remove ( `${ cwd } / ${ stateDir } /artifacts` ) ;
75
- await state . incrementPipelineIid ( cwd , stateDir ) ;
62
+ await fs . remove ( `${ stateDir } /artifacts` ) ;
63
+ await state . incrementPipelineIid ( stateDir ) ;
76
64
}
77
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
65
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
78
66
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs ) ;
79
67
await Utils . rsyncTrackedFiles ( cwd , stateDir , ".docker" ) ;
80
68
await Commander . runJobs ( argv , parser , writeStreams ) ;
81
69
if ( argv . needs || argv . onlyNeeds ) {
82
70
writeStreams . stderr ( chalk `{grey pipeline finished} in {grey ${ prettyHrtime ( process . hrtime ( time ) ) } }\n` ) ;
83
71
}
84
72
} else if ( argv . stage ) {
85
- generateGitIgnore ( cwd , stateDir ) ;
86
73
const time = process . hrtime ( ) ;
87
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
74
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
88
75
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs ) ;
89
76
await Utils . rsyncTrackedFiles ( cwd , stateDir , ".docker" ) ;
90
77
await Commander . runJobsInStage ( argv , parser , writeStreams ) ;
91
78
writeStreams . stderr ( chalk `{grey pipeline finished} in {grey ${ prettyHrtime ( process . hrtime ( time ) ) } }\n` ) ;
92
79
} else {
93
- generateGitIgnore ( cwd , stateDir ) ;
94
80
const time = process . hrtime ( ) ;
95
- await fs . remove ( `${ cwd } / ${ stateDir } /artifacts` ) ;
96
- await state . incrementPipelineIid ( cwd , stateDir ) ;
97
- const pipelineIid = await state . getPipelineIid ( cwd , stateDir ) ;
81
+ await fs . remove ( `${ stateDir } /artifacts` ) ;
82
+ await state . incrementPipelineIid ( stateDir ) ;
83
+ const pipelineIid = await state . getPipelineIid ( stateDir ) ;
98
84
parser = await Parser . create ( argv , writeStreams , pipelineIid , jobs ) ;
99
85
await Utils . rsyncTrackedFiles ( cwd , stateDir , ".docker" ) ;
100
86
await Commander . runPipeline ( argv , parser , writeStreams ) ;
0 commit comments