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


TypeScript globule.find函數代碼示例

本文整理匯總了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);
  });
};
開發者ID:iurimatias,項目名稱:embark-framework,代碼行數:7,代碼來源:code.ts

示例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;
}
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:26,代碼來源:find-files-legacy.ts

示例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;
  },
開發者ID:wordijp,項目名稱:frontend-base-project,代碼行數:46,代碼來源:ambient-external-module.ts

示例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);
	});
});
開發者ID:bitst0rm-dev,項目名稱:a-la-carte,代碼行數:6,代碼來源:webpack.config.ts

示例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']);

開發者ID:EmmaRamirez,項目名稱:DefinitelyTyped,代碼行數:27,代碼來源:globule-tests.ts


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