@@ -7,9 +7,11 @@ import * as state from "./state";
7
7
import { ExitError } from "./types/exit-error" ;
8
8
import { assert } from "./asserts" ;
9
9
10
- const checkFolderAndFile = ( cwd : string ) => {
10
+ const checkFolderAndFile = ( cwd : string , file ?: string ) => {
11
11
assert ( fs . pathExistsSync ( cwd ) , `${ cwd } is not a directory` ) ;
12
- assert ( fs . existsSync ( `${ cwd } /.gitlab-ci.yml` ) , `${ cwd } does not contain .gitlab-ci.yml` ) ;
12
+
13
+ const gitlabFilePath = file ? `${ cwd } /${ file } ` : `${ cwd } /.gitlab-ci.yml` ;
14
+ assert ( fs . existsSync ( gitlabFilePath ) , `${ cwd } does not contain ${ file ?? ".gitlab-ci.yml" } ` ) ;
13
15
} ;
14
16
15
17
exports . command = "$0 [job]" ;
@@ -27,20 +29,20 @@ export async function handler(argv: any) {
27
29
if ( argv . completion != null ) {
28
30
yargs . showCompletionScript ( ) ;
29
31
} else if ( argv . list != null ) {
30
- checkFolderAndFile ( cwd ) ;
32
+ checkFolderAndFile ( cwd , argv . file ) ;
31
33
const pipelineIid = await state . getPipelineIid ( cwd ) ;
32
- const parser = await Parser . create ( cwd , pipelineIid ) ;
34
+ const parser = await Parser . create ( cwd , pipelineIid , false , argv . file ) ;
33
35
Commander . runList ( parser ) ;
34
36
} else if ( argv . job ) {
35
- checkFolderAndFile ( cwd ) ;
37
+ checkFolderAndFile ( cwd , argv . file ) ;
36
38
const pipelineIid = await state . getPipelineIid ( cwd ) ;
37
- const parser = await Parser . create ( cwd , pipelineIid ) ;
39
+ const parser = await Parser . create ( cwd , pipelineIid , false , argv . file ) ;
38
40
await Commander . runSingleJob ( parser , argv . job , argv . needs , argv . privileged ) ;
39
41
} else {
40
- checkFolderAndFile ( cwd ) ;
42
+ checkFolderAndFile ( cwd , argv . file ) ;
41
43
await state . incrementPipelineIid ( cwd ) ;
42
44
const pipelineIid = await state . getPipelineIid ( cwd ) ;
43
- const parser = await Parser . create ( cwd , pipelineIid ) ;
45
+ const parser = await Parser . create ( cwd , pipelineIid , false , argv . file ) ;
44
46
await Commander . runPipeline ( parser , argv . manual || [ ] , argv . privileged ) ;
45
47
}
46
48
}
0 commit comments