Runs hooks.

@param {String[]} hooks List of hook names to execute.
@param {String[]} args
@param {Function} callback
974433
function runHooks(hooks, args, callback) {
    console.log('*** git-hooks.js runHooks', hooks, args);
    if (!hooks.length) {
        callback(0);
        return;
    }
    try {
        var hook = spawnHook(hooks.shift(), args);
        hook.on('close', function (code) {
            if (code === 0) {
                runHooks(hooks, args, callback);
            } else {
                callback(code);
            }
        });
    } catch (e) {
        callback(1, e);
    }
}
1288478
public function hook($hook_spot, $arg = null)
    {
        if (is_null($arg)) {
            $arg = [];
        } elseif (!is_array($arg)) {
            throw new Exception([
                'Arguments for callbacks should be passed as array',
                'arg' => $arg,
            ]);
        }

        $return = [];

        try {
            if (
                isset($this->hooks[$hook_spot])
                && is_array($this->hooks[$hook_spot])
            ) {
                krsort($this->hooks[$hook_spot]); // lower priority is called sooner
                $hook_backup = $this->hooks[$hook_spot];
                while ($_data = array_pop($this->hooks[$hook_spot])) {
                    foreach ($_data as &$data) {
                        $return[] = call_user_func_array(
                            $data[0],
                            array_merge(
                                [$this],
                                $arg,
                                $data[1]
                            )
                        );
                    }
                }

                $this->hooks[$hook_spot] = $hook_backup;
            }
        } catch (HookBreaker $e) {
            $this->hooks[$hook_spot] = $hook_backup;

            return $e->return_value;
        }

        return $return;
    }
187580
def on_load(name, options = {}, &block)
      @loaded[name].each do |base|
        execute_hook(name, base, options, block)
      end

      @load_hooks[name] << [block, options]
    end
783662
function(arg, callback) {
    if (!arg || typeof arg !== 'object') return;

    if (arg instanceof Array) {
      arg.forEach(callback);
    } else {
      for (var k in arg) {
        callback(arg[k], k);
      }
    }
  }
921030
function Hook(hookName, taskNames, options) {

  /**
   * The name of the hook
   * @property hookName
   * @type {String}
   */
  this.hookName = hookName;

  /**
   * The name of the tasks that should be run by the hook, space separated
   * @property taskNames
   * @type {String}
   */
  this.taskNames = taskNames;

  /**
   * Options for the creation of the hook
   * @property options
   * @type {Object}
   */
  this.options = options || {};

  this.markerRegExp = new RegExp(this.options.startMarker.replace(/\//g, '\\/') +
                      '[\\s\\S]*' + // Not .* because it needs to match \n
                      this.options.endMarker.replace(/\//g, '\\/'), 'm');
}
258807
public function hook($hook_spot, $arg = array())
    {
        if (!is_array($arg)) {
            throw $this->exception(
                'Incorrect arguments, or hook does not exist'
            );
        }
        $return = array();
        if ($arg === UNDEFINED) {
            $arg = array();
        }

        if (isset($this->hooks[$hook_spot])) {
            if (is_array($this->hooks[$hook_spot])) {
                krsort($this->hooks[$hook_spot]); // lower priority is called sooner
                $hook_backup = $this->hooks[$hook_spot];

                try {
                    while ($_data = array_pop($this->hooks[$hook_spot])) {
                        foreach ($_data as $prio => &$data) {

                            // Our extension
                            if (is_string($data[0])
                                && !preg_match(
                                    '/^[a-zA-Z_][a-zA-Z0-9_]*$/',
                                    $data[0]
                                )
                            ) {
                                $result = eval($data[0]);
                            } elseif (is_callable($data[0])) {
                                $result = call_user_func_array(
                                    $data[0],
                                    array_merge(
                                        array($this),
                                        $arg,
                                        $data[1]
                                    )
                                );
                            } else {
                                if (!is_array($data[0])) {
                                    $data[0] = array(
                                        'STATIC',
                                        $data[0],
                                    );
                                }
                                throw $this->exception(
                                    'Cannot call hook. Function might not exist.'
                                )
                                    ->addMoreInfo('hook', $hook_spot)
                                    ->addMoreInfo('arg1', $data[0][0])
                                    ->addMoreInfo('arg2', $data[0][1]);
                            }
                            $return[] = $result;
                        }
                    }

                } catch (Exception_Hook $e) {
                    /** @type Exception_Hook $e */
                    $this->hooks[$hook_spot] = $hook_backup;

                    return $e->return_value;
                }

                $this->hooks[$hook_spot] = $hook_backup;
            }
        }

        return $return;
    }
580002
function addHook(hooks, hook) {
    hooks.push(hook)
    return function () {
      var i = hooks.indexOf(hook)
      if (i >= 0) return hooks.splice(i, 1)
    }
  }
1258221
function (callback) {
    var plugins = this.internals.plugins;
    var self = this;

    return Promise.resolve(Object.keys(APIHooks))
      .each(function (hook) {
        var plugin = plugins.hook(hook);
        if (!plugin) return;

        var APIHook = APIHooks[hook].bind(self);

        return Promise.resolve(plugin)
          .map(function (plugin) {
            return plugin[hook]();
          })
          .each(function (args) {
            return APIHook.apply(self, args);
          });
      })
      .asCallback(callback);
  }
831083
public function run($hook, $args = null)
    {
        if (is_array($args)) {
            $this->doActionRefArray($hook, $args);
        } else {
            $this->doAction($hook, $args);
        }

        return $this;
    }
493338
private function runHooks()
    {
        if (class_exists($Hook = 'Josantonius\Hook\Hook')) {
            $Hook::getInstance(self::$id);
            if (isset($this->settings['hooks'])) {
                $Hook::addActions($this->settings['hooks']);
                unset($this->settings['hooks']);
            }
            $Hook::doAction('after-load-hooks');
        }
    }
272467
def run_hook(hook_name, project_dir, context):
    
    script = find_hook(hook_name)
    if script is None:
        logger.debug('No {} hook found'.format(hook_name))
        return
    logger.debug('Running hook {}'.format(hook_name))
    run_script_with_context(script, project_dir, context)
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;
    }
744749
public void run(String[] args) {
        String context = args.length > 0 ? args[0] : "";
        String action = args.length > 1 ? args[1] : "";
        String option = args.length > 2 ? args[2] : "";

        switch (context) {
            case "server":
                server(action, option);
                break;
            case "version":
                version();
                break;
            default:
                help();
        }
    }
523088
function(actionName, args) {
            var self            = this,
                hooks           = self.constructor.actions[actionName],
                extensionName   = '';

            if (!hooks || h.isEmptyObject(hooks)) return;

            for (extensionName in hooks) {
                hooks[extensionName].apply(self, args);
            }
        }
1245374
function execute(args) {
    try {
        const currentOptions = options.parse(args)
        return executeOptions(currentOptions)
    } catch (error) {
        console.error(error.message)
        return 1
    }
}
241428
public void withCallback(String arg, Callback callback) {
        callback.pipe("Hello");
        callback.pipe(arg);
        callback.finish();
    }
51770
def __callbacks(self, msg):
            ''''''
            if self.callback:
                self.callback(msg, *self.callback_args, **self.callback_kwargs)