12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', {
- value: true
- });
- exports.default = void 0;
- function _path() {
- const data = _interopRequireDefault(require('path'));
- _path = function _path() {
- return data;
- };
- return data;
- }
- function _fs() {
- const data = _interopRequireDefault(require('fs'));
- _fs = function _fs() {
- return data;
- };
- return data;
- }
- var _jsonlint = _interopRequireDefault(require('./vendor/jsonlint'));
- var _constants = require('./constants');
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- var _default = configPath => {
- const isJSON = configPath.endsWith('.json');
- let configObject;
- try {
- configObject = require(configPath);
- } catch (error) {
- if (isJSON) {
- throw new Error(
- `Jest: Failed to parse config file ${configPath}\n` +
- ` ${_jsonlint.default.errors(
- _fs().default.readFileSync(configPath, 'utf8')
- )}`
- );
- } else {
- throw error;
- }
- }
- if (configPath.endsWith(_constants.PACKAGE_JSON)) {
-
-
- configObject = configObject.jest || {};
- }
- if (configObject.rootDir) {
-
- if (!_path().default.isAbsolute(configObject.rootDir)) {
-
- configObject.rootDir = _path().default.resolve(
- _path().default.dirname(configPath),
- configObject.rootDir
- );
- }
- } else {
-
- configObject.rootDir = _path().default.dirname(configPath);
- }
- return configObject;
- };
- exports.default = _default;
|