Skip to content

Commit bb1c665

Browse files
committed
Apply fixes.
1 parent 7933df9 commit bb1c665

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

Extension/translations_auto_pr.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
const fs = require("fs-extra");
44
const cp = require("child_process");
5-
let Octokit;
6-
import('@octokit/rest').then(module => {
7-
Octokit = module.Octokit;
8-
});
95
const path = require('path');
106
const parseGitConfig = require('parse-git-config');
117

@@ -186,19 +182,17 @@ console.log(`pushing to remote branch (git push -f origin ${branchName})`);
186182
cp.execSync(`git push -f origin ${branchName}`);
187183

188184
console.log("Checking if there is already a pull request...");
189-
const octokit = new Octokit.Octokit({auth: authToken});
190-
octokit.pulls.list({ owner: repoOwner, repo: repoName }).then(({data}) => {
191-
let alreadyHasPullRequest = false;
192-
if (data) {
193-
data.forEach((pr) => {
194-
alreadyHasPullRequest = alreadyHasPullRequest || (pr.title === pullRequestTitle);
195-
});
196-
}
185+
186+
(async function() {
187+
const { Octokit } = await import("@octokit/rest");
188+
const octokit = new Octokit({ auth: authToken });
189+
const { data } = await octokit.pulls.list({ owner: repoOwner, repo: repoName });
190+
let alreadyHasPullRequest = data && data.some(pr => pr.title === pullRequestTitle);
197191

198192
// If not already present, create a PR against our remote branch.
199193
if (!alreadyHasPullRequest) {
200194
console.log("There is not already a pull request. Creating one.");
201-
octokit.pulls.create({ body:"", owner: repoOwner, repo: repoName, title: pullRequestTitle, head: branchName, base: mergeTo });
195+
await octokit.pulls.create({ body:"", owner: repoOwner, repo: repoName, title: pullRequestTitle, head: branchName, base: mergeTo });
202196
} else {
203197
console.log("There is already a pull request.");
204198
}
@@ -215,4 +209,4 @@ octokit.pulls.list({ owner: repoOwner, repo: repoName }).then(({data}) => {
215209

216210
console.log(`Remove localization branch (git branch -D localization)`);
217211
cp.execSync('git branch -D localization');
218-
});
212+
})();

0 commit comments

Comments
 (0)