UNPKG

749 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.Hooks = undefined;
7
8var _path = require('path');
9
10var _path2 = _interopRequireDefault(_path);
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14const debug = require('debug')('cli-engine:hooks');
15
16class Hooks {
17
18 constructor({ config }) {
19 this.config = config;
20 }
21
22 async run(event, options = {}) {
23 let scripts = this.config.hooks[event];
24 if (!scripts) return;
25 for (let script of scripts) {
26 script = _path2.default.join(this.config.root, script);
27 debug(`%s %s`, event, script);
28 const m = require(script);
29 await m(this.config, options);
30 }
31 }
32}
33exports.Hooks = Hooks;
\No newline at end of file