@@ -12,7 +12,8 @@ export async function buildOptions(
12
12
inputs : Inputs ,
13
13
githubContext : GitHubContext ,
14
14
) {
15
- const { toolchain, source, destination } = getBasicBuildOptions ( inputs ) ;
15
+ const { toolchain, source, destination, artifactName } =
16
+ getBasicBuildOptions ( inputs ) ;
16
17
17
18
const configOverride = {
18
19
gh : getConfigOverride ( inputs . GH_PAGES_BUILD_OVERRIDE ) ,
@@ -35,14 +36,22 @@ export async function buildOptions(
35
36
const flags = [ ] ;
36
37
flags . push ( ...getFailOnFlags ( toolchain , inputs . BUILD_FAIL_ON ) ) ;
37
38
38
- return { toolchain, source, destination, flags, configOverride } ;
39
+ return {
40
+ toolchain,
41
+ source,
42
+ destination,
43
+ artifactName,
44
+ flags,
45
+ configOverride,
46
+ } ;
39
47
}
40
48
41
49
type NormalizedPath = { dir : string ; file : string ; path : string } ;
42
50
export type BasicBuildOptions = {
43
51
toolchain : "respec" | "bikeshed" ;
44
52
source : NormalizedPath ;
45
53
destination : NormalizedPath ;
54
+ artifactName : string ;
46
55
} ;
47
56
function getBasicBuildOptions ( inputs : Inputs ) : BasicBuildOptions {
48
57
let toolchain = inputs . TOOLCHAIN ;
@@ -107,6 +116,21 @@ function getBasicBuildOptions(inputs: Inputs): BasicBuildOptions {
107
116
return { dir, file, path : path . join ( dir , file ) } ;
108
117
} ;
109
118
119
+ const getArtifactNameFromSource = ( source : string ) : string => {
120
+ source = source . toLowerCase ( ) . trim ( ) ;
121
+ const sourceSlug = source
122
+ . replace ( / \/ / g, "-" )
123
+ . replace ( / \s + / g, "-" )
124
+ . replace ( / i n d e x \. ( h t m l | b s ) $ / , "" )
125
+ . replace ( / [ ^ \w - ] + / g, "" )
126
+ . replace ( / - - + / g, "-" )
127
+ . replace ( / - $ / g, "" ) ;
128
+ if ( sourceSlug ) {
129
+ return "spec-prod-result" + "-" + sourceSlug ;
130
+ }
131
+ return "spec-prod-result" ;
132
+ } ;
133
+
110
134
destination = ( ( ) => {
111
135
const dest = path . parse ( destination || source ) ;
112
136
dest . ext = ".html" ;
@@ -116,6 +140,7 @@ function getBasicBuildOptions(inputs: Inputs): BasicBuildOptions {
116
140
117
141
return {
118
142
toolchain,
143
+ artifactName : inputs . ARTIFACT_NAME || getArtifactNameFromSource ( source ) ,
119
144
source : getNormalizedPath ( source ) ,
120
145
destination : getNormalizedPath ( destination ) ,
121
146
} as BasicBuildOptions ;
0 commit comments