1
0
mirror of https://github.com/actions/setup-node synced 2025-05-09 09:27:59 +00:00
setup-node/node_modules/@octokit/auth-token/dist-src/index.js
eric sciple 2b95e76931 .
2020-01-24 12:20:19 -05:00

15 lines
529 B
JavaScript

import { auth } from "./auth";
import { hook } from "./hook";
export const createTokenAuth = function createTokenAuth(token) {
if (!token) {
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
}
if (typeof token !== "string") {
throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
}
token = token.replace(/^(token|bearer) +/i, "");
return Object.assign(auth.bind(null, token), {
hook: hook.bind(null, token)
});
};