Skip to content

Commit 2e88f23

Browse files
[Admin] Update script to bypass user prompt when run from GitHub Action (#2060)
* [Admin] Update script to bypass user prompt when run from GitHub Action * Updates based on feedback
1 parent e0e36c3 commit 2e88f23

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

generate-docs/GenerateDocs.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/bin/bash
22

3+
while getopts b: flag
4+
do
5+
case "${flag}" in
6+
b) bypassPrompt=${OPTARG};;
7+
esac
8+
done
9+
310
if [ -e "build-log.txt" ]; then
411
rm build-log.txt
512
fi
@@ -35,7 +42,7 @@ npm install
3542
pushd scripts
3643
npm install
3744
npm run build
38-
node preprocessor.js
45+
node preprocessor.js $bypassPrompt
3946
popd
4047

4148

generate-docs/scripts/preprocessor.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,30 @@ import * as path from "path";
66
import * as fsx from 'fs-extra';
77

88
tryCatch(async () => {
9-
// ----
10-
// Display prompts
11-
// ----
12-
console.log('\n\n');
9+
const args = process.argv.slice(2);
10+
let sourceChoice;
1311

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+
}
2433

2534

2635
let urlToCopyOfficeJsFrom = "";
@@ -48,6 +57,8 @@ tryCatch(async () => {
4857
// to avoid being redirected to the EDOG environment on corpnet.
4958
// If we ever want to generate not just public d.ts but also "office-with-first-party.d.ts",
5059
// replace the filename.
60+
default:
61+
throw new Error(`Invalid prompt selection: ${sourceChoice}`);
5162
}
5263

5364
console.log("\nStarting preprocessor script...\n");

0 commit comments

Comments
 (0)