Skip to content

Commit 35418fc

Browse files
committed
tweak
1 parent cb0778c commit 35418fc

4 files changed

Lines changed: 332 additions & 300 deletions

File tree

get-changed-packages.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ import micromatch from "micromatch";
1515
import fetch from "node-fetch";
1616
import type { ProbotOctokit } from "probot";
1717

18+
interface PackageJSON extends ChangesetPackageJSON {
19+
workspaces?: Array<string> | { packages: Array<string> };
20+
bolt?: { workspaces: Array<string> };
21+
}
22+
23+
interface PnpmWorkspace {
24+
packages: Array<string>;
25+
}
26+
1827
export const getChangedPackages = async ({
1928
owner,
2029
repo,
@@ -63,11 +72,6 @@ export const getChangedPackages = async ({
6372
}
6473
}
6574

66-
interface PackageJSON extends ChangesetPackageJSON {
67-
workspaces?: Array<string> | { packages: Array<string> };
68-
bolt?: { workspaces: Array<string> };
69-
}
70-
7175
async function getPackage(pkgPath: string): Promise<{ dir: string; packageJson: PackageJSON }> {
7276
const jsonContent = await fetchJsonFile(pkgPath + "/package.json");
7377
return {
@@ -128,10 +132,6 @@ export const getChangedPackages = async ({
128132
| undefined;
129133

130134
if (isPnpm) {
131-
interface PnpmWorkspace {
132-
packages: Array<string>;
133-
}
134-
135135
const pnpmWorkspaceContent = await fetchTextFile("pnpm-workspace.yaml");
136136
const pnpmWorkspace = safeLoad(pnpmWorkspaceContent) as PnpmWorkspace;
137137

index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ export default (app: Probot) => {
151151
// deploying this doesn't cost money
152152
context.payload.action === "synchronize"
153153
? getCommentId(context, { ...repo, issue_number: number })
154-
: Promise.resolve(null),
154+
: undefined,
155155
hasChangesetBeenAdded(changedFilesPromise),
156156
getChangedPackages({
157157
repo: context.payload.pull_request.head.repo.name,
158158
owner: context.payload.pull_request.head.repo.owner.login,
159159
ref: context.payload.pull_request.head.ref,
160-
changedFiles: changedFilesPromise.then((x) => x.data.map(({ filename }) => filename)),
160+
changedFiles: changedFilesPromise.then((files) => files.data.map(({ filename }) => filename)),
161161
octokit: context.octokit,
162162
installationToken: (
163163
await (await app.auth()).apps.createInstallationAccessToken({
@@ -176,7 +176,7 @@ export default (app: Probot) => {
176176
releasePlan: null,
177177
};
178178
}),
179-
] as const);
179+
]);
180180

181181
let addChangesetUrl = `${context.payload.pull_request.head.repo.html_url}/new/${
182182
context.payload.pull_request.head.ref
@@ -195,7 +195,7 @@ export default (app: Probot) => {
195195
errFromFetchingChangedFiles,
196196
};
197197

198-
if (commentId !== null) {
198+
if (typeof commentId === "number") {
199199
return context.octokit.issues.updateComment({
200200
...prComment,
201201
comment_id: commentId,

test/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ function usePrState(apiServer: ReturnType<typeof setupServer>, state: PrState) {
140140
>
141141
> = [];
142142
for (const [filename, file] of Object.entries(state.files)) {
143-
if (typeof file !== "string") {
143+
if (file && typeof file !== "string") {
144144
changedFiles.push({
145145
filename,
146-
status: file![0].status,
146+
status: file[0].status,
147147
});
148148
}
149149
}

0 commit comments

Comments
 (0)