Skip to content

Commit f318804

Browse files
committed
throw Error in function
1 parent 45db2b6 commit f318804

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

dist/index.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,7 @@
133133
const installationToken = resp.token;
134134
// Need to check accessibility if scope set repository
135135
if (scope !== '' && scope.split('/').length === 2) {
136-
const error = yield isExistRepositoryInGitHubApps(
137-
installationToken,
138-
scope
139-
);
140-
if (error.error !== '') {
141-
throw new Error(error.error);
142-
}
136+
yield isExistRepositoryInGitHubApps(installationToken, scope);
143137
}
144138
core.setSecret(installationToken);
145139
core.setOutput('token', installationToken);
@@ -162,11 +156,10 @@
162156
(item) => item.full_name === repository
163157
);
164158
if (repo === undefined) {
165-
return {
166-
error: `GitHub Apps can't accessible repository (${repository})`,
167-
};
159+
throw new Error(
160+
`GitHub Apps can't accessible repository (${repository})`
161+
);
168162
}
169-
return {error: ''};
170163
});
171164
}
172165
run();

src/main.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@ async function run(): Promise<void> {
5151

5252
// Need to check accessibility if scope set repository
5353
if (scope !== '' && scope.split('/').length === 2) {
54-
const error = await isExistRepositoryInGitHubApps(
55-
installationToken,
56-
scope
57-
);
58-
if (error.error !== '') {
59-
throw new Error(error.error);
60-
}
54+
await isExistRepositoryInGitHubApps(installationToken, scope);
6155
}
6256

6357
core.setSecret(installationToken);
@@ -72,7 +66,7 @@ async function run(): Promise<void> {
7266
async function isExistRepositoryInGitHubApps(
7367
installationToken: string,
7468
repository: string
75-
): Promise<{error: string}> {
69+
): Promise<void> {
7670
const installationOctokit = new Octokit({
7771
auth: installationToken,
7872
baseUrl: process.env.GITHUB_API_URL || 'https://api.github.com',
@@ -84,10 +78,8 @@ async function isExistRepositoryInGitHubApps(
8478
(item) => item.full_name === repository
8579
);
8680
if (repo === undefined) {
87-
return {error: `GitHub Apps can't accessible repository (${repository})`};
81+
throw new Error(`GitHub Apps can't accessible repository (${repository})`);
8882
}
89-
90-
return {error: ''};
9183
}
9284

9385
run();

0 commit comments

Comments
 (0)