UNPKG

data-provider-temporary

Version:

Library that helps with server-to-client synchronization of data

129 lines (109 loc) 4.28 kB
'use strict'; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * */ const path = require('path');var _require = require('./utils');const getTestEnvironment = _require.getTestEnvironment,isJSONString = _require.isJSONString; const findConfig = require('./findConfig'); const normalize = require('./normalize'); function readConfig( argv, packageRoot) { const rawOptions = readOptions(argv, packageRoot);var _normalize = normalize(rawOptions, argv);const options = _normalize.options,hasDeprecationWarnings = _normalize.hasDeprecationWarnings;var _getConfigs = getConfigs(options);const globalConfig = _getConfigs.globalConfig,projectConfig = _getConfigs.projectConfig; return { config: projectConfig, globalConfig, hasDeprecationWarnings }; } const parseConfig = argv => isJSONString(argv.config) ? JSON.parse(argv.config) : argv.config; const readOptions = (argv, root) => { const rawOptions = parseConfig(argv); if (typeof rawOptions === 'object') { const config = Object.assign({}, rawOptions); config.rootDir = config.rootDir || root; return config; } if (typeof rawOptions === 'string') { root = path.resolve(process.cwd(), rawOptions); } return findConfig(root); }; const getConfigs = options => { return { globalConfig: Object.freeze({ bail: options.bail, collectCoverage: options.collectCoverage, collectCoverageFrom: options.collectCoverageFrom, collectCoverageOnlyFrom: options.collectCoverageOnlyFrom, coverageDirectory: options.coverageDirectory, coverageReporters: options.coverageReporters, coverageThreshold: options.coverageThreshold, expand: options.expand, forceExit: options.forceExit, logHeapUsage: options.logHeapUsage, mapCoverage: options.mapCoverage, noStackTrace: options.noStackTrace, notify: options.notify, projects: options.projects, replname: options.replname, reporters: options.reporters, rootDir: options.rootDir, silent: options.silent, testNamePattern: options.testNamePattern, testPathPattern: '', testResultsProcessor: options.testResultsProcessor, updateSnapshot: options.updateSnapshot, useStderr: options.useStderr, verbose: options.verbose, watch: options.watch, watchman: options.watchman }), projectConfig: Object.freeze({ automock: options.automock, browser: options.browser, cache: options.cache, cacheDirectory: options.cacheDirectory, clearMocks: options.clearMocks, coveragePathIgnorePatterns: options.coveragePathIgnorePatterns, globals: options.globals, haste: options.haste, moduleDirectories: options.moduleDirectories, moduleFileExtensions: options.moduleFileExtensions, moduleLoader: options.moduleLoader, moduleNameMapper: options.moduleNameMapper, modulePathIgnorePatterns: options.modulePathIgnorePatterns, modulePaths: options.modulePaths, name: options.name, resetMocks: options.resetMocks, resetModules: options.resetModules, resolver: options.resolver, rootDir: options.rootDir, roots: options.roots, setupFiles: options.setupFiles, setupTestFrameworkScriptFile: options.setupTestFrameworkScriptFile, snapshotSerializers: options.snapshotSerializers, testEnvironment: options.testEnvironment, testMatch: options.testMatch, testPathIgnorePatterns: options.testPathIgnorePatterns, testRegex: options.testRegex, testRunner: options.testRunner, testURL: options.testURL, timers: options.timers, transform: options.transform, transformIgnorePatterns: options.transformIgnorePatterns, unmockedModulePathPatterns: options.unmockedModulePathPatterns }) }; }; module.exports = { getTestEnvironment, normalize, readConfig };