UNPKG

549 BJavaScriptView Raw
1var spawn = require('spawn-command');
2var resolve = require('path').resolve;
3
4module.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
9function hook (dirname, filename) {
10 return filename.replace(dirname, '').substr(1);
11}
12
13function 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}