mirror of
https://github.com/actions/hello-world-javascript-action.git
synced 2025-12-16 15:19:19 +00:00
Update packages, change to node16
This commit is contained in:
33
node_modules/@octokit/request-error/dist-src/index.js
generated
vendored
33
node_modules/@octokit/request-error/dist-src/index.js
generated
vendored
@@ -1,6 +1,7 @@
|
||||
import { Deprecation } from "deprecation";
|
||||
import once from "once";
|
||||
const logOnce = once((deprecation) => console.warn(deprecation));
|
||||
const logOnceCode = once((deprecation) => console.warn(deprecation));
|
||||
const logOnceHeaders = once((deprecation) => console.warn(deprecation));
|
||||
/**
|
||||
* Error with extra properties to help with debugging
|
||||
*/
|
||||
@@ -14,18 +15,19 @@ export class RequestError extends Error {
|
||||
}
|
||||
this.name = "HttpError";
|
||||
this.status = statusCode;
|
||||
Object.defineProperty(this, "code", {
|
||||
get() {
|
||||
logOnce(new Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
||||
return statusCode;
|
||||
}
|
||||
});
|
||||
this.headers = options.headers;
|
||||
let headers;
|
||||
if ("headers" in options && typeof options.headers !== "undefined") {
|
||||
headers = options.headers;
|
||||
}
|
||||
if ("response" in options) {
|
||||
this.response = options.response;
|
||||
headers = options.response.headers;
|
||||
}
|
||||
// redact request credentials without mutating original request options
|
||||
const requestCopy = Object.assign({}, options.request);
|
||||
if (options.request.headers.authorization) {
|
||||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||||
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]")
|
||||
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]"),
|
||||
});
|
||||
}
|
||||
requestCopy.url = requestCopy.url
|
||||
@@ -36,5 +38,18 @@ export class RequestError extends Error {
|
||||
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
|
||||
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||||
this.request = requestCopy;
|
||||
// deprecations
|
||||
Object.defineProperty(this, "code", {
|
||||
get() {
|
||||
logOnceCode(new Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
||||
return statusCode;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(this, "headers", {
|
||||
get() {
|
||||
logOnceHeaders(new Deprecation("[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`."));
|
||||
return headers || {};
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user