本文整理匯總了TypeScript中jest-regex-util.escapePathForRegex函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript escapePathForRegex函數的具體用法?TypeScript escapePathForRegex怎麽用?TypeScript escapePathForRegex使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了escapePathForRegex函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createHasteMap
static createHasteMap(
config: Config.ProjectConfig,
options?: HasteMapOptions,
): HasteMap {
const ignorePatternParts = [
...config.modulePathIgnorePatterns,
...(options && options.watch ? config.watchPathIgnorePatterns : []),
config.cacheDirectory.startsWith(config.rootDir + path.sep) &&
config.cacheDirectory,
].filter(Boolean);
const ignorePattern =
ignorePatternParts.length > 0
? new RegExp(ignorePatternParts.join('|'))
: undefined;
return new HasteMap({
cacheDirectory: config.cacheDirectory,
computeSha1: config.haste.computeSha1,
console: options && options.console,
dependencyExtractor: config.dependencyExtractor,
extensions: [Snapshot.EXTENSION].concat(config.moduleFileExtensions),
hasteImplModulePath: config.haste.hasteImplModulePath,
ignorePattern,
maxWorkers: (options && options.maxWorkers) || 1,
mocksPattern: escapePathForRegex(path.sep + '__mocks__' + path.sep),
name: config.name,
platforms: config.haste.platforms || ['ios', 'android'],
providesModuleNodeModules: config.haste.providesModuleNodeModules,
resetCache: options && options.resetCache,
retainAllFiles: false,
rootDir: config.rootDir,
roots: config.roots,
throwOnModuleCollision: config.haste.throwOnModuleCollision,
useWatchman: options && options.watchman,
watch: options && options.watch,
});
}
示例2: escapePathForRegex
config.roots.map(dir => escapePathForRegex(dir + path.sep)).join('|'),
示例3: RegExp
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import path from 'path';
import {Config} from '@jest/types';
import {escapePathForRegex} from 'jest-regex-util';
import {replacePathSepForGlob} from 'jest-util';
import micromatch from 'micromatch';
import {ShouldInstrumentOptions} from './types';
const MOCKS_PATTERN = new RegExp(
escapePathForRegex(path.sep + '__mocks__' + path.sep),
);
export default function shouldInstrument(
filename: Config.Path,
options: ShouldInstrumentOptions,
config: Config.ProjectConfig,
): boolean {
if (!options.collectCoverage) {
return false;
}
if (
config.forceCoverageMatch.length &&
micromatch.any(filename, config.forceCoverageMatch)
) {