diff --git a/.gitignore b/.gitignore
index 4bc5d393441..d2bfafe567f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,6 +53,7 @@ scripts/processDiagnosticMessages.js
scripts/produceLKG.js
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
scripts/generateLocalizedDiagnosticMessages.js
+scripts/request-pr-review.js
scripts/*.js.map
scripts/typings/
coverage/
diff --git a/Gulpfile.js b/Gulpfile.js
index 94212344d38..095ea5025c4 100644
--- a/Gulpfile.js
+++ b/Gulpfile.js
@@ -22,6 +22,9 @@ const copyright = "CopyrightNotice.txt";
const cleanTasks = [];
const buildScripts = () => buildProject("scripts");
+task("scripts", buildScripts);
+task("scripts").description = "Builds files in the 'scripts' folder.";
+
const cleanScripts = () => cleanProject("scripts");
cleanTasks.push(cleanScripts);
diff --git a/scripts/request-pr-review.ts b/scripts/request-pr-review.ts
new file mode 100644
index 00000000000..a9f83ee7e4f
--- /dev/null
+++ b/scripts/request-pr-review.ts
@@ -0,0 +1,73 @@
+///
+///
+import octokit = require("@octokit/rest");
+import Octokit = octokit.Octokit;
+import minimist = require("minimist");
+
+const options = minimist(process.argv.slice(2), {
+ boolean: ["help"],
+ string: ["token", "pull", "reviewer", "owner", "repo"],
+ alias: {
+ pr: "pull",
+ h: "help",
+ ["?"]: "help"
+ },
+ default: {
+ token: process.env.GH_TOKEN,
+ pull: process.env.GH_PULL_NUMBER,
+ reviewer: process.env.REQUESTED_REVIEWER,
+ owner: "microsoft",
+ repo: "TypeScript"
+ }
+});
+
+if (options.help) {
+ printHelpAndExit(0);
+}
+
+if (!options.token || !options.pull || !options.reviewer || !options.owner || !options.repo) {
+ console.error("Invalid arguments");
+ printHelpAndExit(-1);
+}
+
+const pull_number = +options.pull;
+if (!isFinite(pull_number)) {
+ console.error("Invalid arguments");
+ printHelpAndExit(-2);
+}
+
+const reviewers = Array.isArray(options.reviewer) ? options.reviewer : [options.reviewer];
+
+main().catch(console.error);
+
+async function main() {
+ const gh = new Octokit({ auth: options.token });
+ const response = await gh.pulls.createReviewRequest({
+ owner: options.owner,
+ repo: options.repo,
+ pull_number,
+ reviewers,
+ });
+ if (response.status === 201) {
+ console.log(`Added ${reviewers.join(", ")} to ${response.data.url}`);
+ }
+ else {
+ console.log(`Failed to add ${reviewers.join(", ")} to the pull request.`);
+ }
+}
+
+function printHelpAndExit(exitCode: number) {
+ console.log(`
+usage: request-pr-review.js [options]
+
+options:
+ --token Your GitHub auth token. Uses %GH_TOKEN% if present.
+ --owner The GH user or organization for the repo (default: 'microsoft').
+ --repo The GH repo for the pull request (default: 'TypeScript').
+ --pull The pull request number. Uses %GH_PULL_NUMBER% if present.
+ --reviewer The GH username of reviewer to add. May be specified multiple times.
+ Uses %REQUESTED_REVIEWER% if present.
+ -h --help Prints this help message.
+`);
+ return process.exit(exitCode);
+}
\ No newline at end of file
diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json
index e9699c3dc63..8383fbb0ff2 100644
--- a/scripts/tsconfig.json
+++ b/scripts/tsconfig.json
@@ -17,6 +17,7 @@
"configurePrerelease.ts",
"buildProtocol.ts",
"produceLKG.ts",
- "word2md.ts"
+ "word2md.ts",
+ "request-pr-review.ts"
]
}