mirror of
https://github.com/peter-evans/repository-dispatch.git
synced 2026-07-22 02:27:41 +00:00
Replace use of any type
This commit is contained in:
13
dist/index.js
vendored
13
dist/index.js
vendored
@@ -38,6 +38,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
const util_1 = __nccwpck_require__(3837);
|
const util_1 = __nccwpck_require__(3837);
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
function hasErrorStatus(error) {
|
||||||
|
return typeof error.code === 'number';
|
||||||
|
}
|
||||||
|
function getErrorMessage(error) {
|
||||||
|
if (error instanceof Error)
|
||||||
|
return error.message;
|
||||||
|
return String(error);
|
||||||
|
}
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@@ -59,11 +68,11 @@ function run() {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.debug((0, util_1.inspect)(error));
|
core.debug((0, util_1.inspect)(error));
|
||||||
if (error.status == 404) {
|
if (hasErrorStatus(error) && error.status == 404) {
|
||||||
core.setFailed('Repository not found, OR token has insufficient permissions.');
|
core.setFailed('Repository not found, OR token has insufficient permissions.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.setFailed(error.message);
|
core.setFailed(getErrorMessage(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
16
src/main.ts
16
src/main.ts
@@ -2,6 +2,16 @@ import * as core from '@actions/core'
|
|||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import {inspect} from 'util'
|
import {inspect} from 'util'
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
function hasErrorStatus(error: any): error is {status: number} {
|
||||||
|
return typeof error.code === 'number'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getErrorMessage(error: unknown) {
|
||||||
|
if (error instanceof Error) return error.message
|
||||||
|
return String(error)
|
||||||
|
}
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const inputs = {
|
const inputs = {
|
||||||
@@ -22,14 +32,14 @@ async function run(): Promise<void> {
|
|||||||
event_type: inputs.eventType,
|
event_type: inputs.eventType,
|
||||||
client_payload: JSON.parse(inputs.clientPayload)
|
client_payload: JSON.parse(inputs.clientPayload)
|
||||||
})
|
})
|
||||||
} catch (error: any) {
|
} catch (error) {
|
||||||
core.debug(inspect(error))
|
core.debug(inspect(error))
|
||||||
if (error.status == 404) {
|
if (hasErrorStatus(error) && error.status == 404) {
|
||||||
core.setFailed(
|
core.setFailed(
|
||||||
'Repository not found, OR token has insufficient permissions.'
|
'Repository not found, OR token has insufficient permissions.'
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
core.setFailed(error.message)
|
core.setFailed(getErrorMessage(error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user