當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript globby類代碼示例

本文整理匯總了TypeScript中globby的典型用法代碼示例。如果您正苦於以下問題:TypeScript globby類的具體用法?TypeScript globby怎麽用?TypeScript globby使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了globby類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: globby

(async () => {
    let result: string[];
    result = await globby('*.tmp');
    result = await globby(['a.tmp', '*.tmp', '!{c,d,e}.tmp']);

    result = globby.sync('*.tmp');
    result = globby.sync(['a.tmp', '*.tmp', '!{c,d,e}.tmp']);

    result = await globby('*.tmp', Object.freeze({ignore: Object.freeze([])}));
    result = globby.sync('*.tmp', Object.freeze({ignore: Object.freeze([])}));
})();
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:11,代碼來源:globby-tests.ts

示例2: enumerateInstalledCommands

export async function enumerateInstalledCommands(config: CliConfig): Promise<string[]> {
	const { searchPrefixes } = config;
	const globPaths = searchPrefixes.reduce((globPaths: string[], key) => {
		return globPaths.concat(config.searchPaths.map((depPath) => pathResolve(depPath, `${key}-*`)));
	}, []);
	return globby(globPaths, { ignore: '**/*.{map,d.ts}' });
}
開發者ID:dojo,項目名稱:cli,代碼行數:7,代碼來源:loadCommands.ts

示例3: getSchema

export default async function getSchema() {
  const files = await globby('typeDefs/*.graphql', { cwd: __dirname })
  const typeDefs = await Promise.all(
    files.map(async file => {
      const buffer = await readFileAsync(path.join(__dirname, file))
      return buffer.toString()
    })
  )

  return makeExecutableSchema({ typeDefs, resolvers })
}
開發者ID:stipsan,項目名稱:epic,代碼行數:11,代碼來源:schema.ts

示例4: analyze

export async function analyze(
    root: string, inputs: string[]): Promise<AnalysisFormat|undefined> {
  const analyzer = new Analyzer({
    urlLoader: new FSUrlLoader(root),
    urlResolver: new PackageUrlResolver(),
  });

  const isInTests = /(\b|\/|\\)(test)(\/|\\)/;
  const isNotTest = (f: Feature) =>
      f.sourceRange != null && !isInTests.test(f.sourceRange.file);

  if (inputs == null || inputs.length === 0) {
    const _package = await analyzer.analyzePackage();
    return generateAnalysis(_package, '', isNotTest);
  } else {
    const analysis = await analyzer.analyze(await globby(inputs));
    return generateAnalysis(analysis, '', isNotTest);
  }
}
開發者ID:abdonrd,項目名稱:polymer-cli,代碼行數:19,代碼來源:analyze.ts

示例5: run

(async function run() {
  const root = path.resolve(__dirname, '..');
  const resultsPath = path.resolve(root, './src/data/results.json');
  const imageNames = await globby([`*.+(png|gif|jpg|jpeg)`], { cwd: `${root}/images/photoshop` });
  const toolNames = Object.keys(getEmptyResults()) as ToolName[];
  const results: IImage[] = [];

  for (const imageName of imageNames) {
    const extension = getType(imageName);
    const type = imageName.split('_')[0];
    const originalSize = await getSize({ toolName: 'photoshop', imageName });
    const worstSsimPossible =
      extension === 'GIF' ? 1 : await getSsim({ toolName: 'worst', imageName });
    const memo: IResultMemo = {
      bestScore: 0,
      highestSaving: 0,
      image: {
        extension,
        name: imageName,
        results: getEmptyResults(),
        type
      },
      leastLoss: 0
    };

    await Promise.all(
      toolNames.map(async (toolName) => {
        if (await exists({ toolName, imageName })) {
          const result = await getResult(originalSize, worstSsimPossible, { toolName, imageName });
          memo.image.results[toolName] = result;
          memo.bestScore = largest(result.score, memo.bestScore);
          memo.highestSaving = largest(result.sizeSaving, memo.highestSaving);
          memo.leastLoss = largest(result.ssim, memo.leastLoss);
        }
      })
    );

    console.log(imageName);

    for (const toolName of toolNames) {
      const result = memo.image.results[toolName];
      if (result !== null) {
        result.isBestScore = result.score === memo.bestScore;
        result.isHighestSaving = result.sizeSaving === memo.highestSaving;
        result.isLeastLoss = result.sizeSaving > 0 && result.ssim === memo.leastLoss;
        results.push(memo.image);
        console.log(
          [
            toolName,
            result.isBestScore ? ' Best Score' : '',
            result.isHighestSaving ? ' Highest Saving' : '',
            result.isLeastLoss ? ' Least Loss' : ''
          ].join('')
        );
      } else {
        console.log(toolName, 'has no result');
      }
    }
  }

  const previousResults = await readJson(resultsPath);
  await writeJson(resultsPath, results, { spaces: 2 });
  console.log(diffString(previousResults, results));
})();
開發者ID:JamieMason,項目名稱:image-optimisation-tools-comparison,代碼行數:64,代碼來源:update-results.ts

示例6: enumerateBuiltInCommands

export async function enumerateBuiltInCommands(config: CliConfig): Promise<string[]> {
	const builtInCommandParentDirGlob = join(config.builtInCommandLocation, '/*.js');
	return globby(builtInCommandParentDirGlob, { ignore: '**/*.{map,d.ts}' });
}
開發者ID:dojo,項目名稱:cli,代碼行數:4,代碼來源:loadCommands.ts

示例7: next

export default async function resource(compiler: NexeCompiler, next: () => Promise<void>) {
  const resources = compiler.resources

  if (!compiler.options.resources.length) {
    return next()
  }
  const step = compiler.log.step('Bundling Resources...')
  let count = 0
  await each(globs(compiler.options.resources), async file => {
    if (await isDirectoryAsync(file)) {
      return
    }
    count++
    step.log(`Including file: ${file}`)
    const contents = await readFileAsync(file)
    compiler.addResource(file, contents)
  })
  step.log(`Included ${count} file(s). ${(resources.bundle.byteLength / 1e6).toFixed(3)} MB`)
  return next()
}
開發者ID:zavarat,項目名稱:nexe,代碼行數:20,代碼來源:resource.ts


注:本文中的globby類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。