当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript glob.hasMagic函数代码示例

本文整理汇总了TypeScript中glob.hasMagic函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hasMagic函数的具体用法?TypeScript hasMagic怎么用?TypeScript hasMagic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hasMagic函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: expandFiles

export function expandFiles(patterns?: string[] | string) {
  if (!patterns) {
    patterns = [];
  } else if (!Array.isArray(patterns)) {
    patterns = [patterns];
  }

  const excludes: string[] = [];
  const includes: string[] = [];
  const paths: string[] = [];

  for (let pattern of patterns) {
    if (pattern[0] === '!') {
      excludes.push(pattern.slice(1));
    } else {
      if (hasMagic(pattern)) {
        includes.push(pattern);
      } else {
        paths.push(pattern);
      }
    }
  }

  const allPaths = includes
    .map(pattern => glob(pattern, { ignore: excludes }))
    .reduce((allFiles, files) => allFiles.concat(files), paths);
  const uniquePaths: { [name: string]: boolean } = {};
  allPaths.forEach(path => (uniquePaths[path] = true));

  return Object.keys(uniquePaths);
}
开发者ID:theintern,项目名称:intern,代码行数:31,代码来源:util.ts

示例2: expandFiles

export function expandFiles(patterns?: string[] | string) {
	if (!patterns) {
		patterns = [];
	} else if (!Array.isArray(patterns)) {
		patterns = [patterns];
	}

	const excludes: string[] = [];
	const includes: string[] = [];
	const paths: string[] = [];

	for (let pattern of patterns) {
		if (pattern[0] === '!') {
			excludes.push(pattern.slice(1));
		} else {
			if (hasMagic(pattern)) {
				includes.push(pattern);
			} else {
				paths.push(pattern);
			}
		}
	}

	return includes
		.map(pattern => glob(pattern, { ignore: excludes }))
		.reduce((allFiles, files) => allFiles.concat(files), paths);
}
开发者ID:jason0x43,项目名称:intern,代码行数:27,代码来源:util.ts

示例3: resolveFilePatterns

  /**
   * Resolve a list of file patterns into a list of individual file paths.
   *
   * @param {Array.<string> | string} patterns
   * @param {=boolean} opt_omitWarnings Whether to omit did not match warnings
   * @param {=string} opt_relativeTo Path to resolve patterns against
   *
   * @return {Array} The resolved file paths.
   */
  public static resolveFilePatterns(
      patterns: string[]|string, opt_omitWarnings?: boolean, opt_relativeTo?: string): string[] {
    let resolvedFiles: string[] = [];
    let cwd = opt_relativeTo || process.cwd();

    patterns = (typeof patterns === 'string') ? [patterns] : patterns;

    if (patterns) {
      for (let fileName of patterns) {
        let matches = glob.hasMagic(fileName) ? glob.sync(fileName, {cwd}) : [fileName];
        if (!matches.length && !opt_omitWarnings) {
          logger.warn('pattern ' + fileName + ' did not match any files.');
        }
        for (let match of matches) {
          let resolvedPath = path.resolve(cwd, match);
          resolvedFiles.push(resolvedPath);
        }
      }
    }
    return resolvedFiles;
  }
开发者ID:DylanLacey,项目名称:protractor,代码行数:30,代码来源:configParser.ts

示例4: isGlob

 public isGlob(potentialGlob: string): boolean {
   return Glob.hasMagic(potentialGlob);
 }
开发者ID:alsatian-test,项目名称:alsatian,代码行数:3,代码来源:glob-helper.ts


注:本文中的glob.hasMagic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。