@@ -6,21 +6,30 @@ import * as path from "path";
6
6
import * as fsx from 'fs-extra' ;
7
7
8
8
tryCatch ( async ( ) => {
9
- // ----
10
- // Display prompts
11
- // ----
12
- console . log ( '\n\n' ) ;
9
+ const args = process . argv . slice ( 2 ) ;
10
+ let sourceChoice ;
13
11
14
- console . log ( '\n' ) ;
15
- const sourceChoice = await promptFromList ( {
16
- message : `What is the source of the Office-js TypeScript definition files that should be used to generate the docs?` ,
17
- choices : [
18
- { name : "DefinitelyTyped (optimized rebuild)" , value : "DT" } ,
19
- { name : "DefinitelyTyped (full rebuild)" , value : "DT+" } ,
20
- { name : "CDN (if available)" , value : "CDN" } ,
21
- { name : "Local files [generate-docs\\script-inputs\\*.d.ts]" , value : "Local" }
22
- ]
23
- } ) ;
12
+ // Bypass the prompt - for use with the GitHub Action.
13
+ if ( args . length > 0 && args [ 0 ] !== null && args [ 0 ] . trim ( ) . length > 0 ) {
14
+ console . log ( "Bypassing source choice prompt." ) ;
15
+ sourceChoice = args [ 0 ] . trim ( ) ;
16
+ } else {
17
+ // ----
18
+ // Display prompts
19
+ // ----
20
+ console . log ( '\n\n' ) ;
21
+
22
+ console . log ( '\n' ) ;
23
+ sourceChoice = await promptFromList ( {
24
+ message : `What is the source of the Office-js TypeScript definition files that should be used to generate the docs?` ,
25
+ choices : [
26
+ { name : "DefinitelyTyped (optimized rebuild)" , value : "DT" } ,
27
+ { name : "DefinitelyTyped (full rebuild)" , value : "DT+" } ,
28
+ { name : "CDN (if available)" , value : "CDN" } ,
29
+ { name : "Local files [generate-docs\\script-inputs\\*.d.ts]" , value : "Local" }
30
+ ]
31
+ } ) ;
32
+ }
24
33
25
34
26
35
let urlToCopyOfficeJsFrom = "" ;
@@ -48,6 +57,8 @@ tryCatch(async () => {
48
57
// to avoid being redirected to the EDOG environment on corpnet.
49
58
// If we ever want to generate not just public d.ts but also "office-with-first-party.d.ts",
50
59
// replace the filename.
60
+ default :
61
+ throw new Error ( `Invalid prompt selection: ${ sourceChoice } ` ) ;
51
62
}
52
63
53
64
console . log ( "\nStarting preprocessor script...\n" ) ;
0 commit comments