"use strict";

var cov_242ewvhlu5 = function () {
  var path = "/home/travis/build/commitizen/cz-cli/src/common/util.js";
  var hash = "bc7147643a51aded92d9cfa9976b5026f592e01a";
  var global = new Function("return this")();
  var gcv = "__coverage__";
  var coverageData = {
    path: "/home/travis/build/commitizen/cz-cli/src/common/util.js",
    statementMap: {
      "0": {
        start: {
          line: 15,
          column: 2
        },
        end: {
          line: 20,
          column: 3
        }
      },
      "1": {
        start: {
          line: 16,
          column: 30
        },
        end: {
          line: 16,
          column: 86
        }
      },
      "2": {
        start: {
          line: 17,
          column: 4
        },
        end: {
          line: 17,
          column: 43
        }
      },
      "3": {
        start: {
          line: 19,
          column: 4
        },
        end: {
          line: 19,
          column: 21
        }
      },
      "4": {
        start: {
          line: 27,
          column: 2
        },
        end: {
          line: 27,
          column: 53
        }
      },
      "5": {
        start: {
          line: 34,
          column: 2
        },
        end: {
          line: 42,
          column: 3
        }
      },
      "6": {
        start: {
          line: 36,
          column: 4
        },
        end: {
          line: 36,
          column: 17
        }
      },
      "7": {
        start: {
          line: 37,
          column: 9
        },
        end: {
          line: 42,
          column: 3
        }
      },
      "8": {
        start: {
          line: 38,
          column: 4
        },
        end: {
          line: 38,
          column: 17
        }
      },
      "9": {
        start: {
          line: 40,
          column: 18
        },
        end: {
          line: 40,
          column: 20
        }
      },
      "10": {
        start: {
          line: 41,
          column: 4
        },
        end: {
          line: 41,
          column: 93
        }
      },
      "11": {
        start: {
          line: 46,
          column: 2
        },
        end: {
          line: 46,
          column: 41
        }
      }
    },
    fnMap: {
      "0": {
        name: "getParsedJsonFromFile",
        decl: {
          start: {
            line: 14,
            column: 9
          },
          end: {
            line: 14,
            column: 30
          }
        },
        loc: {
          start: {
            line: 14,
            column: 71
          },
          end: {
            line: 21,
            column: 1
          }
        },
        line: 14
      },
      "1": {
        name: "getParsedPackageJsonFromPath",
        decl: {
          start: {
            line: 26,
            column: 9
          },
          end: {
            line: 26,
            column: 37
          }
        },
        loc: {
          start: {
            line: 26,
            column: 45
          },
          end: {
            line: 28,
            column: 1
          }
        },
        line: 26
      },
      "2": {
        name: "isFunction",
        decl: {
          start: {
            line: 33,
            column: 9
          },
          end: {
            line: 33,
            column: 19
          }
        },
        loc: {
          start: {
            line: 33,
            column: 38
          },
          end: {
            line: 43,
            column: 1
          }
        },
        line: 33
      },
      "3": {
        name: "isInTest",
        decl: {
          start: {
            line: 45,
            column: 9
          },
          end: {
            line: 45,
            column: 17
          }
        },
        loc: {
          start: {
            line: 45,
            column: 21
          },
          end: {
            line: 47,
            column: 1
          }
        },
        line: 45
      }
    },
    branchMap: {
      "0": {
        loc: {
          start: {
            line: 14,
            column: 52
          },
          end: {
            line: 14,
            column: 69
          }
        },
        type: "default-arg",
        locations: [{
          start: {
            line: 14,
            column: 63
          },
          end: {
            line: 14,
            column: 69
          }
        }],
        line: 14
      },
      "1": {
        loc: {
          start: {
            line: 34,
            column: 2
          },
          end: {
            line: 42,
            column: 3
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 34,
            column: 2
          },
          end: {
            line: 42,
            column: 3
          }
        }, {
          start: {
            line: 34,
            column: 2
          },
          end: {
            line: 42,
            column: 3
          }
        }],
        line: 34
      },
      "2": {
        loc: {
          start: {
            line: 37,
            column: 9
          },
          end: {
            line: 42,
            column: 3
          }
        },
        type: "if",
        locations: [{
          start: {
            line: 37,
            column: 9
          },
          end: {
            line: 42,
            column: 3
          }
        }, {
          start: {
            line: 37,
            column: 9
          },
          end: {
            line: 42,
            column: 3
          }
        }],
        line: 37
      },
      "3": {
        loc: {
          start: {
            line: 41,
            column: 11
          },
          end: {
            line: 41,
            column: 92
          }
        },
        type: "binary-expr",
        locations: [{
          start: {
            line: 41,
            column: 11
          },
          end: {
            line: 41,
            column: 26
          }
        }, {
          start: {
            line: 41,
            column: 30
          },
          end: {
            line: 41,
            column: 92
          }
        }],
        line: 41
      }
    },
    s: {
      "0": 0,
      "1": 0,
      "2": 0,
      "3": 0,
      "4": 0,
      "5": 0,
      "6": 0,
      "7": 0,
      "8": 0,
      "9": 0,
      "10": 0,
      "11": 0
    },
    f: {
      "0": 0,
      "1": 0,
      "2": 0,
      "3": 0
    },
    b: {
      "0": [0],
      "1": [0, 0],
      "2": [0, 0],
      "3": [0, 0]
    },
    _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184",
    hash: "bc7147643a51aded92d9cfa9976b5026f592e01a"
  };
  var coverage = global[gcv] || (global[gcv] = {});

  if (coverage[path] && coverage[path].hash === hash) {
    return coverage[path];
  }

  return coverage[path] = coverageData;
}();

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getParsedJsonFromFile = getParsedJsonFromFile;
exports.getParsedPackageJsonFromPath = getParsedPackageJsonFromPath;
exports.isFunction = isFunction;
exports.isInTest = isInTest;

var _fs = _interopRequireDefault(require("fs"));

var _path = _interopRequireDefault(require("path"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Gets the parsed contents of a json file
 */
function getParsedJsonFromFile(filePath, fileName, encoding = (cov_242ewvhlu5.b[0][0]++, 'utf8')) {
  cov_242ewvhlu5.f[0]++;
  cov_242ewvhlu5.s[0]++;

  try {
    var packageJsonContents = (cov_242ewvhlu5.s[1]++, _fs.default.readFileSync(_path.default.join(filePath, fileName), encoding));
    cov_242ewvhlu5.s[2]++;
    return JSON.parse(packageJsonContents);
  } catch (e) {
    cov_242ewvhlu5.s[3]++;
    console.error(e);
  }
}
/**
 * A helper method for getting the contents of package.json at a given path
 */


function getParsedPackageJsonFromPath(path) {
  cov_242ewvhlu5.f[1]++;
  cov_242ewvhlu5.s[4]++;
  return getParsedJsonFromFile(path, 'package.json');
}
/**
 * Test if the passed argument is a function
 */


function isFunction(functionToCheck) {
  cov_242ewvhlu5.f[2]++;
  cov_242ewvhlu5.s[5]++;

  if (typeof functionToCheck === "undefined") {
    cov_242ewvhlu5.b[1][0]++;
    cov_242ewvhlu5.s[6]++;
    return false;
  } else {
    cov_242ewvhlu5.b[1][1]++;
    cov_242ewvhlu5.s[7]++;

    if (functionToCheck === null) {
      cov_242ewvhlu5.b[2][0]++;
      cov_242ewvhlu5.s[8]++;
      return false;
    } else {
      cov_242ewvhlu5.b[2][1]++;
      var getType = (cov_242ewvhlu5.s[9]++, {});
      cov_242ewvhlu5.s[10]++;
      return (cov_242ewvhlu5.b[3][0]++, functionToCheck) && (cov_242ewvhlu5.b[3][1]++, getType.toString.call(functionToCheck) === '[object Function]');
    }
  }
}

function isInTest() {
  cov_242ewvhlu5.f[3]++;
  cov_242ewvhlu5.s[11]++;
  return typeof global.it === 'function';
}