保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 26fa49f4b0aa658d65a21fffe828f39e78302573
PAMapp/node_modules/jest-config/build/readConfigFileAndSetRootDir.js
@@ -25,6 +25,26 @@
  return data;
}
function _parseJson() {
  const data = _interopRequireDefault(require('parse-json'));
  _parseJson = function () {
    return data;
  };
  return data;
}
function _stripJsonComments() {
  const data = _interopRequireDefault(require('strip-json-comments'));
  _stripJsonComments = function () {
    return data;
  };
  return data;
}
function _jestUtil() {
  const data = require('jest-util');
@@ -36,8 +56,6 @@
}
var _constants = require('./constants');
var _jsonlint = _interopRequireDefault(require('./vendor/jsonlint'));
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {default: obj};
@@ -91,7 +109,6 @@
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
// @ts-expect-error: vendored
// Read the configuration and set its `rootDir`
// 1. If it's a `package.json` file, we look into its "jest" property
// 2. If it's a `jest.config.ts` file, we use `ts-node` to transpile & require it
@@ -105,23 +122,24 @@
  try {
    if (isTS) {
      configObject = await loadTSConfigFile(configPath);
    } else if (isJSON) {
      const fileContent = fs().readFileSync(configPath, 'utf8');
      configObject = (0, _parseJson().default)(
        (0, _stripJsonComments().default)(fileContent),
        configPath
      );
    } else {
      configObject = await (0, _jestUtil().requireOrImportModule)(configPath);
    }
  } catch (error) {
    if (isJSON) {
      throw new Error(
        `Jest: Failed to parse config file ${configPath}\n` +
          `  ${_jsonlint.default.errors(fs().readFileSync(configPath, 'utf8'))}`
      );
    } else if (isTS) {
    if (isTS) {
      throw new Error(
        `Jest: Failed to parse the TypeScript config file ${configPath}\n` +
          `  ${error}`
      );
    } else {
      throw error;
    }
    throw error;
  }
  if (configPath.endsWith(_constants.PACKAGE_JSON)) {
@@ -149,17 +167,19 @@
  }
  return configObject;
} // Load the TypeScript configuration
}
let registerer; // Load the TypeScript configuration
const loadTSConfigFile = async configPath => {
  let registerer; // Register TypeScript compiler instance
  // Register TypeScript compiler instance
  try {
    registerer = require('ts-node').register({
      compilerOptions: {
        module: 'CommonJS'
      }
    });
    registerer ||
      (registerer = require('ts-node').register({
        compilerOptions: {
          module: 'CommonJS'
        }
      }));
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND') {
      throw new Error(