當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。