1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2024-12-23 05:34:56 +00:00
setup-node/node_modules/before-after-hook/index.d.ts
Danny McCormick 78148dae50
Add auth support (#21)
* Updates

* Update

* Update

* Update

* Update

* Yarn sometimes prefers npmrc, so use same token

* Description

* Update readme

* Feedback

* Add type

* new toolkit and scoped registries

* npmrc in RUNNER_TEMP

* Dont always auth

* Try exporting blank token

* Get auth working for now pending runner changes

* Fix string interpolation for auth token.

* Don't export both userconfigs

* Update authutil.js

* Add single quotes for authString

* Fix the registry string.

* Use userconfig and append trailing slash

* Keep in root of repo

* Try just adding auth token

* Remove auth token

* Try changes again

* Add tests

* Npm and GPR samples

* Add types
2019-08-06 18:26:04 -04:00

96 lines
2.1 KiB
TypeScript

type HookMethod<O, R> = (options: O) => R | Promise<R>
type BeforeHook<O> = (options: O) => void
type ErrorHook<O, E> = (error: E, options: O) => void
type AfterHook<O, R> = (result: R, options: O) => void
type WrapHook<O, R> = (
hookMethod: HookMethod<O, R>,
options: O
) => R | Promise<R>
type AnyHook<O, R, E> =
| BeforeHook<O>
| ErrorHook<O, E>
| AfterHook<O, R>
| WrapHook<O, R>
export interface HookCollection {
/**
* Invoke before and after hooks
*/
(
name: string | string[],
hookMethod: HookMethod<any, any>,
options?: any
): Promise<any>
/**
* Add `before` hook for given `name`
*/
before(name: string, beforeHook: BeforeHook<any>): void
/**
* Add `error` hook for given `name`
*/
error(name: string, errorHook: ErrorHook<any, any>): void
/**
* Add `after` hook for given `name`
*/
after(name: string, afterHook: AfterHook<any, any>): void
/**
* Add `wrap` hook for given `name`
*/
wrap(name: string, wrapHook: WrapHook<any, any>): void
/**
* Remove added hook for given `name`
*/
remove(name: string, hook: AnyHook<any, any, any>): void
}
export interface HookSingular<O, R, E> {
/**
* Invoke before and after hooks
*/
(hookMethod: HookMethod<O, R>, options?: O): Promise<R>
/**
* Add `before` hook
*/
before(beforeHook: BeforeHook<O>): void
/**
* Add `error` hook
*/
error(errorHook: ErrorHook<O, E>): void
/**
* Add `after` hook
*/
after(afterHook: AfterHook<O, R>): void
/**
* Add `wrap` hook
*/
wrap(wrapHook: WrapHook<O, R>): void
/**
* Remove added hook
*/
remove(hook: AnyHook<O, R, E>): void
}
type Collection = new () => HookCollection
type Singular = new <O = any, R = any, E = any>() => HookSingular<O, R, E>
interface Hook {
new (): HookCollection
/**
* Creates a collection of hooks
*/
Collection: Collection
/**
* Creates a nameless hook that supports strict typings
*/
Singular: Singular
}
export const Hook: Hook
export const Collection: Collection
export const Singular: Singular
export default Hook