'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = keyGetter;

var _fsExtra;

function _load_fsExtra() {
  return _fsExtra = _interopRequireDefault(require('fs-extra'));
}

var _utils;

function _load_utils() {
  return _utils = require('../../../utils');
}

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

function readKey(keyPath) {
  if (!keyPath) return '';

  try {
    return (_fsExtra || _load_fsExtra()).default.readFileSync(keyPath);
  } catch (e) {
    return '';
  }
}

function keyGetter(keyPath) {
  if (keyPath) return readKey(keyPath);
  return readKey((0, (_utils || _load_utils()).identityFile)());
}