'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.




getContextPackagePath = getContextPackagePath;exports.



getFilePackagePath = getFilePackagePath;exports.




getFilePackageName = getFilePackageName;var _path = require('path');var _findUp = require('find-up');var _findUp2 = _interopRequireDefault(_findUp);var _readPkgUp = require('read-pkg-up');var _readPkgUp2 = _interopRequireDefault(_readPkgUp);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}function getContextPackagePath(context) {return getFilePackagePath(context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename());}function getFilePackagePath(filePath) {var fp = _findUp2['default'].sync('package.json', { cwd: filePath });return (0, _path.dirname)(fp);}function getFilePackageName(filePath) {var _readPkgUp$sync =
  _readPkgUp2['default'].sync({ cwd: filePath, normalize: false }),pkg = _readPkgUp$sync.pkg,path = _readPkgUp$sync.path;
  if (pkg) {
    // recursion in case of intermediate esm package.json without name found
    return pkg.name || getFilePackageName((0, _path.dirname)((0, _path.dirname)(path)));
  }
  return null;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb3JlL3BhY2thZ2VQYXRoLmpzIl0sIm5hbWVzIjpbImdldENvbnRleHRQYWNrYWdlUGF0aCIsImdldEZpbGVQYWNrYWdlUGF0aCIsImdldEZpbGVQYWNrYWdlTmFtZSIsImNvbnRleHQiLCJnZXRQaHlzaWNhbEZpbGVuYW1lIiwiZ2V0RmlsZW5hbWUiLCJmaWxlUGF0aCIsImZwIiwiZmluZFVwIiwic3luYyIsImN3ZCIsInJlYWRQa2dVcCIsIm5vcm1hbGl6ZSIsInBrZyIsInBhdGgiLCJuYW1lIl0sIm1hcHBpbmdzIjoiOzs7OztBQUtnQkEscUIsR0FBQUEscUI7Ozs7QUFJQUMsa0IsR0FBQUEsa0I7Ozs7O0FBS0FDLGtCLEdBQUFBLGtCLENBZGhCLDRCQUNBLGlDLCtDQUNBLHdDLG9KQUdPLFNBQV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