1
1
import * as fs from "fs" ;
2
2
import * as path from "path" ;
3
3
4
- export function toBooleanConfig ( configValue ) {
4
+ export function toBooleanConfig ( configValue : string | boolean ) : boolean {
5
5
if ( configValue && typeof configValue === 'string' ) {
6
6
return ( configValue === 'true' )
7
7
}
8
- return configValue
8
+ return configValue as boolean
9
9
}
10
10
11
- export function toArrayConfig ( configValue , separator = ',' , fallback ?: any ) {
11
+ export function toArrayConfig ( configValue : string | [ ] , separator = ',' , fallback ?: string [ ] ) : string [ ] {
12
12
if ( configValue && typeof configValue === 'string' ) {
13
13
return ( configValue . split ( separator ) . map ( arrayItem => arrayItem . trim ( ) ) )
14
14
}
15
15
return fallback
16
16
}
17
17
18
- export function toIntegerConfig ( configValue ) {
18
+ export function toIntegerConfig ( configValue : string | number ) : number {
19
19
if ( configValue && typeof configValue === 'string' ) {
20
20
return parseInt ( configValue )
21
21
}
22
- return configValue
22
+ return configValue as number
23
23
}
24
24
25
- export function getGitCommit ( repodir ) {
25
+ export function getGitCommit ( repodir : string ) : string {
26
26
if ( ! fs . existsSync ( repodir + '/.git/HEAD' ) ) {
27
27
return undefined
28
28
}
@@ -35,7 +35,7 @@ export function getGitCommit(repodir) {
35
35
return reference
36
36
}
37
37
38
- export function getGitHubURL ( repo , reference ) {
38
+ export function getGitHubURL ( repo : string , reference : string ) : string {
39
39
// if it's not a github reference, we handle handle that anyway
40
40
if ( ! repo . startsWith ( 'https://github.com' ) && ! repo . startsWith ( 'git@github.com' ) ) {
41
41
return repo
0 commit comments