本文整理汇总了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)
) {