• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// @ts-check
2/// <reference lib="esnext.asynciterable" />
3// Must reference esnext.asynciterable lib, since octokit uses AsyncIterable internally
4const { Octokit } = require("@octokit/rest");
5const fs = require("fs");
6
7const requester = process.env.requesting_user;
8const source = process.env.source_issue;
9const postedComment = process.env.status_comment;
10console.log(`Loading fragment from ${process.argv[3]}...`);
11const outputTableText = fs.readFileSync(process.argv[3], { encoding: "utf8" });
12console.log(`Fragment contents:
13${outputTableText}`);
14
15const gh = new Octokit({
16    auth: process.argv[2]
17});
18gh.issues.createComment({
19    issue_number: +source,
20    owner: "Microsoft",
21    repo: "TypeScript",
22    body: `@${requester}
23The results of the perf run you requested are in!
24<details><summary> Here they are:</summary><p>
25${outputTableText}
26</p></details>`
27}).then(async data => {
28    console.log(`Results posted!`);
29    const newCommentUrl = data.data.html_url;
30    const comment = await gh.issues.getComment({
31        owner: "Microsoft",
32        repo: "TypeScript",
33        comment_id: +postedComment
34    });
35    const newBody = `${comment.data.body}
36
37Update: [The results are in!](${newCommentUrl})`;
38    return await gh.issues.updateComment({
39        owner: "Microsoft",
40        repo: "TypeScript",
41        comment_id: +postedComment,
42        body: newBody
43    });
44}).catch(e => {
45    console.error(e);
46    process.exit(1);
47});
48