本文整理汇总了TypeScript中globby.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript globby.default方法的具体用法?TypeScript globby.default怎么用?TypeScript globby.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globby
的用法示例。
在下文中一共展示了globby.default方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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 })
}
示例2: resource
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()
}
示例3: 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([])}));
})();
示例4: globby
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}' });
}
示例5: generateAnalysis
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);
}
}
示例6: writeJson
(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));
})();