'use strict';

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

var _fs;

function _load_fs() {
  return _fs = _interopRequireWildcard(require('fs'));
}

var _utils;

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

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

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

  try {
    return (_fs || _load_fs()).readFileSync(keyPath);
  } catch (e) {
    return '';
  }
}

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