1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.Hooks = undefined;
|
7 |
|
8 | var _path = require('path');
|
9 |
|
10 | var _path2 = _interopRequireDefault(_path);
|
11 |
|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13 |
|
14 | const debug = require('debug')('cli-engine:hooks');
|
15 |
|
16 | class 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 | }
|
33 | exports.Hooks = Hooks; |
\ | No newline at end of file |