All files / lib/setup install.js

100% Statements 17/17
100% Branches 4/4
100% Functions 2/2
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30    2x 2x 2x   2x   2x 4x   4x 4x   4x 1x     3x     3x 36x 2x     1x 1x    
'use strict';
 
const hooks = require('./hooks');
const hookScript = require('./hook-script');
const { findHooksDir, isSetupRequired } = require('./utils');
 
const debug = require('debug')('gint:setup');
 
module.exports = (gintDir, logger) => {
  const hooksDir = findHooksDir(gintDir);
 
  debug('Syncing...');
  debug('%O', { hooksDir, gintDir });
 
  if (!isSetupRequired(gintDir)) {
    return false;
  }
 
  logger('Installing Git hooks');
 
 
  if (hooksDir) {
    hooks.forEach((hookName) => hookScript.sync(gintDir, hooksDir, hookName));
    return true;
  }
 
  logger('gint > Cannot find .git directory, skipping Git hooks installation');
  return false;
};