本文整理汇总了TypeScript中globule.find函数的典型用法代码示例。如果您正苦于以下问题:TypeScript find函数的具体用法?TypeScript find怎么用?TypeScript find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: replacePureView
export const removePureView = (dir: string) => {
globule.find(path.join(dir, "**/*.sol")).forEach((filepath) => {
let source = fs.readFileSync(filepath, "utf-8");
source = replacePureView(source);
fs.writeFileSync(filepath, source);
});
};
示例2: findFiles
export function findFiles(pattern: any, includeDir: boolean, cwd?: string): string[] {
let patterns: string[] = [];
let baseDir = isNullOrWhitespace(cwd) ? process.cwd() : cwd;
tl.debug('Input pattern: ' + pattern + ' cwd: ' + baseDir);
if (typeof pattern === 'string') {
patterns = [pattern];
} else if (pattern instanceof Array) {
patterns = pattern;
}
let searchPattern = extractPattern(patterns, baseDir);
let globPattern: string[] = searchPattern.includePatterns;
searchPattern.excludePatterns.forEach(p => globPattern.push('!' + p));
tl.debug('Glob pattern: ' + JSON.stringify(globPattern));
let result = globule.find(globPattern);
tl.debug('Glob result length: ' + result.length);
if (!includeDir) {
return result.filter(isFile);
}
return result;
}
示例3: defaults
collect: (conf) => {
// 未定義の時はDefault値
var config = defaults(conf, {
root: 'src',
include_ext: ['.ts', '.coffee'],
exclude_ext: ['.d.ts']
});
// プロジェクト内のソースを収集
var includes = config.include_ext.map((x) => { return config.root + '/**/*' + x; });
var excludes = config.exclude_ext.map((x) => { return '!' + config.root + '/**/*' + x; });
var files = globule.find(includes.concat(excludes));
// ファイルからタグ一覧を収集する
var tags = Enumerable.from(files)
.select((file) => {
var ret = grepSync(['-w', tag_name, file]);
if (!ret) {
return {};
}
var type_value = ret.split(tag_name)[1].trim();
var split = type_value.split('=');
var type = split[0];
var value = split[1];
// value内の文字列を取り出す
var matched = value.match(/[\"\'](.+)[\"\']/);
if (!matched) {
errLog("failed to value.match file:" + file);
return {};
}
var parsed_value = parseValues(matched[1], file);
return toTagObject(file, type, parsed_value);
})
.where((obj) => { return Object.keys(obj).length > 0; })
.toArray();
//console.log("-----------------------");
//console.log("tags:");
//console.log(tags);
//console.log("-----------------------");
return tags;
},
示例4: RegExp
Object.keys(convertExt).forEach(from => {
const to = convertExt[(from as convertExtFrom)];
globule.find([`**/*.${from}`, `!**/_*.${from}`], {cwd: dir.src}).forEach(filename => {
files[filename.replace(new RegExp(`.${from}$`), `.${to}`)] = path.join(dir.src, filename);
});
});
示例5:
import * as globule from 'globule';
let filepaths: string[];
filepaths = globule.find('**/*.js');
filepaths = globule.find(['**/*.js']);
filepaths = globule.find('**/*.js', '**/*.less');
filepaths = globule.find('*.js', { matchBase: true });
filepaths = globule.find('**/*.js', '**/*.less', { filter: 'isFile' });
filepaths = globule.find('**/*.js', '**/*.less', { filter: /jQuery/i.test });
filepaths = globule.find({ src: '**/*.js' });
filepaths = globule.match('*.js', '/home/code');
filepaths = globule.match('*.js', '/home/code', { matchBase: true });
let bResult: boolean;
bResult = globule.isMatch('*.js', '/home/code');
bResult = globule.isMatch('*.js', '/home/code', { matchBase: true });
let mappings = globule.mapping(['*.js']);
const len = mappings.length;
const src = mappings[0].src;
const dest = mappings[0].dest;
mappings = globule.mapping(['*.js'], { srcBase: '/home/code' });
mappings = globule.mapping(['*.js', '*.less']);
mappings = globule.mapping(['*.js'], ['*.less']);