• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript shelljs.find函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中shelljs.find函数的典型用法代码示例。如果您正苦于以下问题:TypeScript find函数的具体用法?TypeScript find怎么用?TypeScript find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了find函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: findAllPackageJsonFiles

export function findAllPackageJsonFiles(rootDirectory: string): string[] {
  // TODO(gkalpak): Investigate whether skipping `node_modules/` directories (instead of traversing
  //                them and filtering out the results later) makes a noticeable difference.
  const paths = Array.from(find(rootDirectory));
  return paths.filter(
      path => PACKAGE_JSON_REGEX.test(path) &&
          !NODE_MODULES_REGEX.test(path.slice(rootDirectory.length)));
}
开发者ID:hulkike,项目名称:angular,代码行数:8,代码来源:utils.ts


示例2: it

  it('should run ngcc without errors', () => {
    const nodeModulesPath = path.join(basePath, 'node_modules');
    console.error(nodeModulesPath);
    const commonPath = path.join(nodeModulesPath, '@angular/common');
    const exitCode = mainNgcc([commonPath]);

    console.warn(find('node_modules_ngtsc').filter(p => p.endsWith('.js') || p.endsWith('map')));

    console.warn(cat('node_modules_ngtsc/@angular/common/fesm2015/common.js').stdout);
    console.warn(cat('node_modules_ngtsc/@angular/common/fesm2015/common.js.map').stdout);

    expect(exitCode).toBe(0);
  });
开发者ID:hulkike,项目名称:angular,代码行数:13,代码来源:ngcc_spec.ts


示例3: convertLfToCrlfAll

    async function convertLfToCrlfAll(baseDir: string) {
        await Promise.all<{ target: string, content: string }>(
            shell
                .find(baseDir)
                .filter(target => {
                    const match = target.match(/\.(.+)$/);
                    return (
                        (!match && target.endsWith("LICENSE")) ||
                        (match &&
                            (match[1] === "html" ||
                                match[1] === "js" ||
                                match[1] === "css" ||
                                match[1] === "txt" ||
                                match[1] === "ini"
                            ))
                    );
                })
                .map(
                    target =>
                        new Promise((resolve, reject) => {
                            fs.readFile(target, (err, data) => {
                                if (err) {
                                    console.error(err);
                                    reject(err);
                                    return;
                                }
                                resolve({
                                    target,
                                    content: convertLfToCrlf(data.toString("utf8"))
                                });
                            })
                        })
                )
        ).then(contents =>
            contents.map(
                prop =>
                    new Promise((resolve, reject) =>
                        fs.writeFile(prop.target, prop.content, err => {
                            if (err) {
                                console.error(err);
                                reject(err);
                                return;
                            }
                            resolve();
                        })
                    )
            )
        );

    }
开发者ID:WWAWing,项目名称:WWAWing,代码行数:50,代码来源:make-wwawing-dist.ts


示例4: _cleanFiles

    private _cleanFiles(callback: (err: any) => void): void {
        this.emitter.emit('info', 'Cleaning Files: ' + this.path);
        if (!shell.test('-d', this.path)) {
            callback(null);
            return;
        }

        var candidates = shell.find(this.path).filter((file) => { return this.ext === '*' || file.endsWith('.' + this.ext); });

        var _that = this;
        var delCount = 0;
        async.forEachSeries(candidates,
            function (candidate, done: (err: any) => void) {
                fs.stat(candidate, (err, stats) => {
                    if (err) {
                        done(null);
                        return;
                    }

                    if (stats.isDirectory()) {
                        done(null);
                        return;
                    }

                    var fileAgeSeconds = (new Date().getTime() - stats.mtime.getTime()) / 1000;
                    if (fileAgeSeconds > _that.ageSeconds) {
                        ++delCount;
                        _that.emitter.emit('deleted', candidate);
                        shell.rm(candidate);
                    }                    

                    // ignoring errors - log and keep going
                    done(null);
                })
            }, function (err) {
                _that.emitter.emit('info', 'deleted file count: ' + delCount);
                // ignoring errors. log and go
                callback(null);
            });        
    }
开发者ID:itsananderson,项目名称:vso-agent,代码行数:40,代码来源:diagnostics.ts


示例5: expect

 () => { expect(shx.find('esm5').filter(f => f.endsWith('.ngsummary.js'))).toEqual([]); });
开发者ID:zackarychapple,项目名称:angular,代码行数:1,代码来源:core_package.spec.ts


示例6: it

 it('should not contain any *.ngsummary.js files', () => {
   expect(shx.find('esm2015').filter(f => f.endsWith('.ngsummary.js'))).toEqual([]);
 });
开发者ID:zackarychapple,项目名称:angular,代码行数:3,代码来源:core_package.spec.ts


示例7: main


//.........这里部分代码省略.........
    shx.mkdir('-p', path.dirname(outputPath));
    fs.writeFileSync(outputPath, fileContent, 'utf-8');
  }

  /**
   * Copies a file into the package based on its input path, relativizing to the package path.
   * @param inputPath a path relative to the binDir, typically from a file in the deps[]
   */
  function copyFileFromInputPath(inputPath: string) {
    writeFileFromInputPath(inputPath, fs.readFileSync(inputPath, 'utf-8'));
  }

  /**
   * Relativize the path where a file is written.
   * @param file a path containing a re-rooted segment like .esm5 or .es6
   * @param suffix the re-rooted directory
   * @param outDir path where we copy the file, relative to the out
   */
  function writeEsmFile(file: string, suffix: string, outDir: string) {
    const root = file.substr(0, file.lastIndexOf(suffix + path.sep) + suffix.length + 1);
    const rel = path.dirname(path.relative(path.join(root, srcDir), file));
    if (!rel.startsWith('..')) {
      copyFile(file, path.join(out, outDir), rel);
    }
  }

  esm2015.forEach(file => writeEsmFile(file, '.es6', 'esm2015'));
  esm5.forEach(file => writeEsmFile(file, '.esm5', 'esm5'));

  bundles.forEach(bundle => { copyFile(bundle, out, 'bundles'); });
  fesm2015.forEach(file => { copyFile(file, out, 'fesm2015'); });
  fesm5.forEach(file => { copyFile(file, out, 'fesm5'); });

  const allsrcs = shx.find('-R', binDir);
  allsrcs.filter(hasFileExtension('.d.ts')).forEach((f: string) => {
    const content = fs.readFileSync(f, 'utf-8')
                        // Strip the named AMD module for compatibility with non-bazel users
                        .replace(/^\/\/\/ <amd-module name=.*\/>\n/, '');
    writeFileFromInputPath(f, content);
  });

  // Copy all `data` files into the package. These are files that aren't built by the ng_package
  // rule, but instead are just straight copied into the package, e.g. global CSS assets.
  dataFiles.forEach(f => copyFileFromInputPath(f));

  // Iterate through the entry point modules
  // We do this first because we also record new paths for the esm5 and esm2015 copies
  // of the index JS file, which we need to amend the package.json.
  Object.keys(modulesManifest).forEach(moduleName => {
    const moduleFiles = modulesManifest[moduleName];
    const relative = path.relative(binDir, moduleFiles['index']);

    moduleFiles['esm5_index'] = path.join(binDir, 'esm5', relative);
    moduleFiles['esm2015_index'] = path.join(binDir, 'esm2015', relative);

    copyFileFromInputPath(moduleFiles['metadata']);
  });

  // Root package name (e.g. '@angular/common'), captures as we iterate through sources below.
  let rootPackageName = '';
  const packagesWithExistingPackageJson = new Set<string>();

  for (const src of srcs) {
    if (src.includes(binDir) || src.includes(genfilesDir)) {
      errorHasOccured = true;
      console.error(
开发者ID:IdeaBlade,项目名称:angular,代码行数:67,代码来源:packager.ts


示例8: mdUrl

const tpl = sh.cat(template);

// Prepare output folder (create, clean, copy sources)
sh.mkdir("-p", output);
sh.rm("-rf", output + "/*");
sh.cp("-R", folder + "/*", output);

// Start processing. Outline:
//
// 1. Get all files
// 2. Sort them
// 3. Group them hierachically
// 4. Parse files and generate output html files

sh.cd(output);
const all = sh.find("*");

const mds = all
  .filter(file => file.match(mdR))
  .sort(sortByPreferences.bind(null, preferences))
  .map(file => {
    const content = sh.cat(file).toString(); // The result is a weird not-string
    return {
      path: file,
      url: mdUrl(file),
      content,
      html: md2html(content)
    };
  });

const groupedMds: FileTree<StringFile> = mds.reduce(
开发者ID:joakin,项目名称:markdown-folder-to-html,代码行数:31,代码来源:cli.ts


示例9: main

function main(args: string[]): number {
  shx.set('-e');
  const
      [out, srcDir, binDir, readmeMd, fesms2015Arg, fesms5Arg, bundlesArg, srcsArg, stampData,
       licenseFile] = args;
  const fesms2015 = fesms2015Arg.split(',').filter(s => !!s);
  const fesms5 = fesms5Arg.split(',').filter(s => !!s);
  const bundles = bundlesArg.split(',').filter(s => !!s);
  const srcs = srcsArg.split(',').filter(s => !!s);

  shx.mkdir('-p', out);

  let primaryEntryPoint: string|null = null;
  const secondaryEntryPoints = new Set<string>();

  function replaceVersionPlaceholders(filePath: string) {
    if (stampData) {
      const version = shx.grep('BUILD_SCM_VERSION', stampData).split(' ')[1].trim();
      return shx.sed(/0.0.0-PLACEHOLDER/, version, filePath);
    }
    return shx.cat(filePath);
  }

  function writeFesm(file: string, baseDir: string) {
    const parts = path.basename(file).split('__');
    const entryPointName = parts.join('/').replace(/\..*/, '');
    if (primaryEntryPoint === null || primaryEntryPoint === entryPointName) {
      primaryEntryPoint = entryPointName;
    } else {
      secondaryEntryPoints.add(entryPointName);
    }
    const filename = parts.splice(-1)[0];
    const dir = path.join(baseDir, ...parts);
    shx.mkdir('-p', dir);
    shx.cp(file, dir);
    shx.mv(path.join(dir, path.basename(file)), path.join(dir, filename));
  }

  function moveBundleIndex(f: string) {
    let ext: string;

    if (f.endsWith('.d.ts'))
      ext = '.d.ts';
    else if (f.endsWith('.metadata.json'))
      ext = '.metadata.json';
    else
      throw new Error('Bundle index files should be .d.ts or .metadata.json');

    const relative = path.relative(binDir, f);
    let outputPath: string|undefined = undefined;
    for (const secondary of secondaryEntryPoints.values()) {
      if (relative.startsWith(secondary)) {
        const filename = secondary.split('/').pop();
        outputPath = path.join(out, secondary, filename + ext);
      }
    }
    if (!outputPath) {
      outputPath = path.join(out, primaryEntryPoint + ext);
    }
    return outputPath;
  }

  if (readmeMd) {
    shx.cp(readmeMd, path.join(out, 'README.md'));
  }

  fesms2015.forEach(fesm2015 => writeFesm(fesm2015, path.join(out, 'esm2015')));
  fesms5.forEach(fesm5 => writeFesm(fesm5, path.join(out, 'esm5')));

  const bundlesDir = path.join(out, 'bundles');
  shx.mkdir('-p', bundlesDir);
  bundles.forEach(bundle => { shx.cp(bundle, bundlesDir); });

  const allsrcs = shx.find('-R', binDir);
  allsrcs.filter(filter('.d.ts')).forEach((f: string) => {
    const content = fs.readFileSync(f, {encoding: 'utf-8'})
                        // Strip the named AMD module for compatibility with non-bazel users
                        .replace(/^\/\/\/ <amd-module name=.*\/>\n/, '');
    let outputPath: string;
    if (f.endsWith('.bundle_index.d.ts')) {
      outputPath = moveBundleIndex(f);
    } else {
      outputPath = path.join(out, path.relative(binDir, f));
    }
    shx.mkdir('-p', path.dirname(outputPath));
    fs.writeFileSync(outputPath, content);
  });

  for (const src of srcs) {
    replaceVersionPlaceholders(src).to(path.join(out, path.relative(srcDir, src)));
  }

  allsrcs.filter(filter('.bundle_index.metadata.json')).forEach((f: string) => {
    replaceVersionPlaceholders(f).to(moveBundleIndex(f));
  });

  const licenseBanner = licenseFile ? fs.readFileSync(licenseFile, {encoding: 'utf-8'}) : '';

  for (const secondaryEntryPoint of secondaryEntryPoints.values()) {
    const baseName = secondaryEntryPoint.split('/').pop();
//.........这里部分代码省略.........
开发者ID:robwormald,项目名称:angular,代码行数:101,代码来源:packager.ts


示例10:

import * as path from 'path';
import * as shell from 'shelljs';

// 清理上传目录
shell.rm('-rf', 'upload');
shell.mkdir('upload');

// 同步资源文件
shell.find('src').filter(item => {
  return item.match(/\.(html|ico)$/);
}).forEach(item => {
  const dest = item.replace(/^src\b/, 'dist');
  shell.mkdir('-p', path.dirname(dest));
  shell.cp(item, dest);
});
开发者ID:whosesmile,项目名称:koa-scaffold,代码行数:15,代码来源:sync.static.ts



注:本文中的shelljs.find函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript shelljs.grep函数代码示例发布时间:2022-05-25
下一篇:
TypeScript shelljs.exec函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap