Installs the hook without checking if it already exists
482028
function actuallyInstallHook(
			hookToCopy,
			whereToPutIt,
			sourceCanonicalName
		) {
			mkpath.sync( path.join( './', path.dirname( whereToPutIt ) ) );
			exec( 'cp ' + hookToCopy + ' ' + whereToPutIt );
			grunt.log.writeln( [
				'Installed ', sourceCanonicalName, ' hook in ', whereToPutIt
			].join( '' ).green );
		}
353082
public function addHook(HookFactory $hook): void
	{
		$hook->init();
		$this->hooks[$hook->name] = $hook;
	}
475188
public function updateHooks() {
	    
	    if(Auth::isAdmin()){
	        $ihooks = self::getInstalledHooks();
	        $phooks = self::getPossibleHooks();
	        	
	        // Insert hooks not existing yet in the DB
	        if($phooks !== null){
	            foreach($phooks as $phook => $priority){
	                $array_hook = explode('#', $phook);
	                if($ihooks === null || !array_key_exists($phook, $ihooks)){
	                    $chook = new Hook($array_hook[1], $array_hook[2]);
	                    $chook->subscribe($array_hook[0]);
	                    $chook->setPriority($array_hook[0], $priority);
	                }
	            }
	        }
	        	
	        //Remove hooks not existing any more in the file system
	        if($ihooks !== null){
	            foreach(array_keys($ihooks) as $ihook){
	                $array_hook = explode('#', $ihook);
	                if($phooks === null || !array_key_exists($ihook, $phooks)){
	                    $chook = new Hook($array_hook[1], $array_hook[2]);
	                    $chook->remove($array_hook[0]);
	                }
	            }
	        }
	    }
	}
1361183
def detect_hooks():
    
    flog.debug('Detecting hooks ...')
    present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path])
    if present:
        flog.debug('Detected.')
    else:
        flog.debug('Not detected.')
    return present
1235717
function hook() {
      var comp = hook.proxy.apply(null, arguments);
      for(var i = 0;i < hooks.length;i++) {
        hooks[i].apply(comp, arguments);
      }
      return comp;
    }
198512
def autohook(ui, repo, hooktype, **kwargs):
    """"""
    cmd = hooktype.replace("-", "_")
    if not repo or not cmd.replace("_", "").isalpha():
        return False
    result = False
    trusted = ui.configlist("autohooks", "trusted")
    if "" not in trusted:
        default_path = ui.config("paths", "default")
        if not default_path:
            return False
        for match in trusted:
            if default_path.startswith(match):
                break
        else:
            return False
    for hookdir in ("hg-autohooks", ".hg-autohooks"):
        dirname = os.path.join(repo.root, hookdir)
        if not os.path.exists(dirname):
            continue
        for leafname in os.listdir(dirname):
            if not leafname.startswith(cmd + "."):
                continue
            filename = os.path.join(dirname, leafname)
            result = _runhook(ui, repo, hooktype, filename, kwargs) or result
    return result
984019
function install (presetName) {
  debug('run install from scripts, arguments: %o', arguments)

  const name = presetName || tryRequire(/elint-preset-/)[0]

  if (!name) {
    debug('can not fount preset, return')
    return
  }

  const nodeModulesDir = getNodeModulesDir()
  const keep = process.env.npm_config_keep || ''
  const presetModulePath = path.join(nodeModulesDir, name)

  link(presetModulePath, keep)
}
1032018
function (workingDirectory) {
        var gitPath = getClosestGitPath(workingDirectory);

        if (!gitPath) {
            throw new Error('git-hooks must be run inside a git repository');
        }

        var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
        var pathToGitHooks = path.join(path.relative(hooksPath, __dirname), 'git-hooks');
 
        if (isWin32) {
            pathToGitHooks = pathToGitHooks.replace(/\\/g, '\\\\');
        }

        if (fsHelpers.exists(hooksOldPath)) {
            throw new Error('git-hooks already installed');
        }

        if (fsHelpers.exists(hooksPath)) {
            fs.renameSync(hooksPath, hooksOldPath);
        }

        var hookTemplate = fs.readFileSync(__dirname + '/' + HOOKS_TEMPLATE_FILE_NAME);
        var pathToGitHooks = path.relative(hooksPath, __dirname);
        // Fix non-POSIX (Windows) separators
        pathToGitHooks = pathToGitHooks.replace(new RegExp(path.sep.replace(/\\/g, '\\$&'), 'g'), '/');
        var hook = util.format(hookTemplate.toString(), pathToGitHooks);

        fsHelpers.makeDir(hooksPath);
        HOOKS.forEach(function (hookName) {
            var hookPath = path.resolve(hooksPath, hookName);
            try {
                fs.writeFileSync(hookPath, hook, {mode: '0777'});
            } catch (e) {
                // node 0.8 fallback
                fs.writeFileSync(hookPath, hook, 'utf8');
                fs.chmodSync(hookPath, '0777');
            }
        });
    }
935081
def extern(obj, timeout=200):
    
    global installed

    # Register it just once.
    if not installed: 
        install_hook(obj, timeout)
    installed = True
893793
def add_hook(name = nil, cascade = false, &hook)
    if name == nil or name == true or name == false
      cascade = name
      assign_self_hook(cascade, &hook)
    else
      assign_hook(name_to_a(name), cascade, &hook)
    end
  end
87359
def add_hook(self, key_name, hook_name, hook_dict):
        """"""
        kf = self.dct[key_name]
        if 'hooks' not in kf:
            kf['hooks'] = {}
        kf['hooks'][str(hook_name)] = hook_dict
1017056
def get_hook(hook_name):
    
    if not pkg_resources.resource_exists(__name__, hook_name):
        raise HookNotFoundError
    return pkg_resources.resource_string(__name__, hook_name)
512472
def add_hook(self, name, function):
        
        if not callable(function):
            return ValueError('Hook function should be callable')
        if name not in self.hooks:
            self.hooks[name] = []
        self.hooks[name].append(function)
        return self
594659
function Hook(fn, options) {
  if (!this) return new Hook(fn, options);
  options = options || {};

  this.options = options;     // Used for testing only. Ignore this. Don't touch.
  this.config = {};           // pre-commit configuration from the `package.json`.
  this.json = {};             // Actual content of the `package.json`.
  this.npm = '';              // The location of the `npm` binary.
  this.git = '';              // The location of the `git` binary.
  this.root = '';             // The root location of the .git folder.
  this.status = '';           // Contents of the `git status`.
  this.exit = fn;             // Exit function.

  this.initialize();
}
728723
function getHook(className, hookType) {
  if (hooks[className] && hooks[className][hookType]) {
    return hooks[className][hookType];
  }
  return undefined;
}
1112622
def hook(self, name):
        
        def wrapper(func):
            self.hooks.add(name, func)
            return func
        return wrapper
693813
public function setHook(string $hook) : Installer
    {
        if (!empty($hook) && !Util::isValid($hook)) {
            throw new Exception\InvalidHookName('Invalid hook name \'' . $hook . '\'');
        }
        $this->hookToHandle = $hook;
        return $this;
    }