MCPcopy
hub / github.com/tj/commander.js / hook

Method hook

lib/command.js:488–500  ·  view source on GitHub ↗

* Add hook for life cycle event. * * @param {string} event * @param {Function} listener * @return {Command} `this` command for chaining

(event, listener)

Source from the content-addressed store, hash-verified

486 */
487
488 hook(event, listener) {
489 const allowedValues = ['preSubcommand', 'preAction', 'postAction'];
490 if (!allowedValues.includes(event)) {
491 throw new Error(`Unexpected value for event passed to hook : '${event}'.
492Expecting one of '${allowedValues.join("', '")}'`);
493 }
494 if (this._lifeCycleHooks[event]) {
495 this._lifeCycleHooks[event].push(listener);
496 } else {
497 this._lifeCycleHooks[event] = [listener];
498 }
499 return this;
500 }
501
502 /**
503 * Register callback to use as replacement for calling process.exit.

Callers 5

hook.jsFile · 0.80
index.test-d.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected