本文整理汇总了TypeScript中globby.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: lintAsync
export async function lintAsync(filePatterns = defaultFilePatterns) {
const filePaths = await globby(filePatterns);
const contents = await Promise.all(filePaths.map(filePath => fs.readFileAsync(filePath, 'utf8')));
const results = filePaths.map((filePath, index) => {
const content = contents[index];
const linter = new TsLinter(filePath, content, options);
return linter.lint();
});
const failures = results.filter(result => !!result.failureCount);
return failures;
}
示例2: resource
export default async function resource(compiler: NexeCompiler, next: () => Promise<any>) {
const { cwd } = compiler.options
if (!compiler.options.resources.length) {
return next()
}
const step = compiler.log.step('Bundling Resources...')
let count = 0
await each(globs(compiler.options.resources, { cwd }), async file => {
if (await isDirectoryAsync(file)) {
return
}
count++
step.log(`Including file: ${file}`)
await compiler.addResource(file)
})
step.log(`Included ${count} file(s). ${(compiler.resourceSize / 1e6).toFixed(3)} MB`)
return next()
}
示例3: reset
public async reset() {
this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache will reset');
// start by deleting the state file to lower the
// amount of time that another process might be able to
// successfully read it once we decide to delete it
await del(this.statePath);
// delete everything in optimize/.cache directory
// except ts-node
await del(
await globby(
[
normalizePosixPath(this.cachePath),
`${normalizePosixPath(`!${this.cachePath}/ts-node/**`)}`,
],
{ dot: true }
)
);
// delete some empty folder that could be left
// from the previous cache path reset action
await deleteEmpty(this.cachePath);
// delete dlls
await del(this.dllsPath);
// re-write new cache state file
await this.write();
this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache has reset');
}
示例4: writeFileAsync
export async function formatAsync(filePatterns = sourceFilePatterns) {
const filePaths = await globby(filePatterns, { absolute: true });
const contents = await Promise.all(
filePaths.map(filePath => readFileAsync(filePath, 'utf8'))
);
const fixedFiles: string[] = [];
await Promise.all(
filePaths.map(async (filePath, index) => {
const content = contents[index];
let formattedContent;
try {
formattedContent = format(content, options);
} catch (err) {
error(`Couldn't format ${red(filePath)}.`);
throw err;
}
if (content !== formattedContent) {
fixedFiles.push(filePath);
await writeFileAsync(filePath, formattedContent);
}
})
);
return fixedFiles;
}
示例5: buildProductionProjects
async () => {
await buildProductionProjects({ kibanaRoot: tmpDir, buildRoot, onlyOSS: true });
const files = await globby(['**/*', '!**/node_modules/**'], {
cwd: buildRoot,
});
expect(files.sort()).toMatchSnapshot();
},
示例6: getIntlLocales
export async function getIntlLocales(): Promise<LocaleMap> {
if (!cachedLocales) {
const intlPath = await resolve('intl');
const cwd = join(dirname(intlPath), 'locale-data/jsonp');
const localeFiles = await globby('*.js', { cwd });
const locales = localeFiles.map((file) => basename(file, '.js'));
cachedLocales = {};
locales.forEach((key) => (cachedLocales[key] = true));
}
return cachedLocales;
}
示例7: generateTypings
export async function generateTypings(
declarationDir: string,
filePatterns = sourceFilePatterns
) {
if (project.typings) {
debug('Generate typings.');
const filePaths = await globby(filePatterns);
const options = {
declaration: true,
declarationDir
};
const result = createProgram(filePaths, options).emit(
undefined, // targetSourceFile
undefined, // writeFile
undefined, // cancellationToken
true // emitOnlyDtsFiles
);
if (result.diagnostics.length) {
const message = result.diagnostics
.map(({ messageText, file, start }) => {
if (file && start) {
const pos = file.getLineAndCharacterOfPosition(start);
const frame = codeFrame(
file.getFullText(),
pos.line + 1,
pos.character + 1,
{
highlightCode: true
}
);
return `${messageText}\n${frame}`;
} else {
return messageText;
}
})
.join('\n');
throw `\n${message}\n`;
}
// check if they exist at the same place where it is configured in your package.json
const exist = await existsAsync(join(process.cwd(), project.typings));
if (!exist) {
throw `${red('typings')} do not exist in ${project.typings}`;
}
}
}
示例8: discoverModules
/**
* Function to list plugins from a specific directory. The returned array consists of module names
* relative to the passed-in directory.
*/
async function discoverModules(directory: string): Promise<string[]> {
// Given the tree structure below, this function returns the array ['Foo', 'Bar', 'Baz']:
// * plugins/
// * Foo/
// * Bar.js
// * Baz/
//
// Here's how:
// 1. globby('*', cwd: plugins) => [Foo, Bar.js, Baz] (directories don't have suffixes)
// 2. path.basename(module, .js) => [Foo, Bar, Baz] (extension in basename() is optional)
//
// We use path.basename() to prettify the module names. It's compatible with how require() sees
// the world, as it will attempt to add the .js extension back before falling back to finding
// an index.js file in the named directory. So long as the modules are given good names, they
// can be presented to the user directly in a menu or printed out for debugging.
const modules = await globby('*', { cwd: directory, onlyFiles: false });
return modules.map(moduleName => path.basename(moduleName, '.js'));
}
示例9: through
files.forEach(filepath => {
console.log(filepath);
var bundledStream = through();
var fileParts = filepath.split('/');
var directory = fileParts.slice(0, fileParts.length - 1).join('/');
var filename = fileParts[fileParts.length - 1].replace('.ts', '.out.js');
if (filename == 'app.js')
return;
if (filename.indexOf('.out.out.') !== -1) {
return;
}
console.log(`dir: ${directory} filename: ${filename}`);
bundledStream
.pipe(source(filename))
.pipe(buffer())
// .pipe(sm.init({loadMaps: true}))
// .pipe(uglify())
// .pipe(sm.write('./'))
.pipe(gulp.dest(directory));
globby(taskPath, function(err, entries) {
if (err) {
bundledStream.emit('error', err);
return;
}
var b = browserify({
entries: [filepath],
debug: true,
paths: ['scripts'],
noParse:['lodash.js'],
standalone: 'GLib'
}).plugin('tsify',{target:'es5'});
b.bundle().pipe(bundledStream);
});
});