File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { Aws } from 'aws-cdk-lib' ;
2
- import ci from 'env-ci' ;
2
+ import ci , { AppveyorEnv } from 'env-ci' ;
3
3
import Haikunator , { Options as HaikunatorOptions } from 'haikunator' ;
4
4
5
- function fromCI ( name : 'branch' | 'commit' | 'build' | 'job' | 'pr' | 'slug' ) : IStaticWebsitePreviewNamingToken {
6
- const c = ci ( ) ;
5
+ // The env-ci package has some funky type union setup per each CI environment, and we cannot
6
+ // handle every use case, so just generalize this by taking one of the environments that has types
7
+ // for all of the keys that we care about
8
+ type GenericCiEnv = AppveyorEnv
7
9
8
- if ( name in c ) {
9
- const val = c [ name ] ;
10
+ function fromCI ( name : keyof GenericCiEnv ) : IStaticWebsitePreviewNamingToken {
10
11
11
- if ( val ) {
12
- return new StaticWebsitePreviewNamingToken ( val ) ;
13
- }
12
+ const c = ci ( ) as GenericCiEnv ;
13
+ const val = c [ name ] ;
14
+
15
+ if ( typeof val === 'string' && val ) {
16
+ return new StaticWebsitePreviewNamingToken ( val ) ;
14
17
}
15
18
16
19
throw new Error ( `The value for "${ name } " is not set.` ) ;
You can’t perform that action at this time.
0 commit comments