* Representation of a hook runner. * * @constructor * @param {Function} fn Function to be called when we want to exit * @param {Object} options Optional configuration, primarily used for testing. * @api public
(fn, options)
| 15 | * @api public |
| 16 | */ |
| 17 | function Hook(fn, options) { |
| 18 | if (!this) return new Hook(fn, options); |
| 19 | options = options || {}; |
| 20 | |
| 21 | this.options = options; // Used for testing only. Ignore this. Don't touch. |
| 22 | this.config = {}; // pre-commit configuration from the `package.json`. |
| 23 | this.json = {}; // Actual content of the `package.json`. |
| 24 | this.npm = ''; // The location of the `npm` binary. |
| 25 | this.git = ''; // The location of the `git` binary. |
| 26 | this.root = ''; // The root location of the .git folder. |
| 27 | this.status = ''; // Contents of the `git status`. |
| 28 | this.exit = fn; // Exit function. |
| 29 | |
| 30 | this.initialize(); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Boolean indicating if we're allowed to output progress information into the |