1 | var spawn = require('spawn-command');
|
2 | var resolve = require('path').resolve;
|
3 |
|
4 | module.exports = function run (dirname, filename) {
|
5 | var command = commandFor(hook(dirname, filename));
|
6 | if (command) spawn(command, { stdio: 'inherit' }).on('exit', process.exit);
|
7 | };
|
8 |
|
9 | function hook (dirname, filename) {
|
10 | return filename.replace(dirname, '').substr(1);
|
11 | }
|
12 |
|
13 | function commandFor (hook) {
|
14 | var pkg = require(resolve(process.cwd(), 'package'));
|
15 | if (pkg.config && pkg.config.ghooks && pkg.config.ghooks[hook]) {
|
16 | return pkg.config.ghooks[hook];
|
17 | }
|
18 | }
|