mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-23 02:29:33 +01:00
78148dae50
* 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
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
var register = require('./lib/register')
|
|
var addHook = require('./lib/add')
|
|
var removeHook = require('./lib/remove')
|
|
|
|
// bind with array of arguments: https://stackoverflow.com/a/21792913
|
|
var bind = Function.bind
|
|
var bindable = bind.bind(bind)
|
|
|
|
function bindApi (hook, state, name) {
|
|
var removeHookRef = bindable(removeHook, null).apply(null, name ? [state, name] : [state])
|
|
hook.api = { remove: removeHookRef }
|
|
hook.remove = removeHookRef
|
|
|
|
;['before', 'error', 'after', 'wrap'].forEach(function (kind) {
|
|
var args = name ? [state, kind, name] : [state, kind]
|
|
hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args)
|
|
})
|
|
}
|
|
|
|
function HookSingular () {
|
|
var singularHookName = 'h'
|
|
var singularHookState = {
|
|
registry: {}
|
|
}
|
|
var singularHook = register.bind(null, singularHookState, singularHookName)
|
|
bindApi(singularHook, singularHookState, singularHookName)
|
|
return singularHook
|
|
}
|
|
|
|
function HookCollection () {
|
|
var state = {
|
|
registry: {}
|
|
}
|
|
|
|
var hook = register.bind(null, state)
|
|
bindApi(hook, state)
|
|
|
|
return hook
|
|
}
|
|
|
|
var collectionHookDeprecationMessageDisplayed = false
|
|
function Hook () {
|
|
if (!collectionHookDeprecationMessageDisplayed) {
|
|
console.warn('[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4')
|
|
collectionHookDeprecationMessageDisplayed = true
|
|
}
|
|
return HookCollection()
|
|
}
|
|
|
|
Hook.Singular = HookSingular.bind()
|
|
Hook.Collection = HookCollection.bind()
|
|
|
|
module.exports = Hook
|
|
// expose constructors as a named property for TypeScript
|
|
module.exports.Hook = Hook
|
|
module.exports.Singular = Hook.Singular
|
|
module.exports.Collection = Hook.Collection
|