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

TypeScript globby.sync函数代码示例

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

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



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

示例1: 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([])}));
})();
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:11,代码来源:globby-tests.ts


示例2: mapLimit

const parseAndReportFiles = (fileGlobs: string[], program: ReporterProgramArgs): void => {
    // Get all files and their resolved globs
    const files = globby.sync(fileGlobs, {
        cwd: process.cwd(),
        ignore: program.ignore || [],
        onlyFiles: true,
    });

    if (!files || !files.length) {
        console.log(logSymbols.warning, 'No files found for reporting');
        process.exit(1);
    }

    // Parallel read all of the given files
    mapLimit(
        files,
        concurrencyLimit,
        (file, cb) => readFile(resolve(process.cwd(), file), 'utf8', cb),
        (err, results: string[]) => {
            if (err) {
                console.log(err);
                process.exit(1);
            }
            const todos = results
                .map(content => JSON.parse(content))
                // filter files without any parsed content
                .filter(item => item && item.length > 0)
                .reduce((items, item) => items.concat(item), []);

            outputTodos(todos, program);
        }
    );
};
开发者ID:pgilad,项目名称:leasot,代码行数:33,代码来源:cli-reporter.ts


示例3: getFiles

 getFiles(): Files {
   return {
     lists: globby
       .sync('*.json', {
         cwd: path.join(this.importDir, 'lists/'),
       })
       .map(p => path.join(this.importDir, 'lists/', p)),
     nodes: globby
       .sync('*.json', {
         cwd: path.join(this.importDir, 'nodes/'),
       })
       .map(p => path.join(this.importDir, 'nodes/', p)),
     relations: globby
       .sync('*.json', {
         cwd: path.join(this.importDir, 'relations/'),
       })
       .map(p => path.join(this.importDir, 'relations/', p)),
   }
 }
开发者ID:ahmb84,项目名称:prisma,代码行数:19,代码来源:Importer.ts


示例4: execute

        /**
         * Misc resources are special because a single file input may generate multiple
         * input/output configurations.
         *
         * Let's take an example. If you have a configuration like:
         *
         * misc:
         *   input: 'assets/images/**'
         *   output: 'public/images'
         *
         * This will copy every file in the 'assets/images' folder into 'public/images'.
         * But 'assets/images' may contain sub folders, and if so, they have to be kept!
         *
         * So the line "input: 'assets/images/**'" will generate as many input/output configurations
         * as there are sub folders when resolving the glob.
         *
         * It's a bit ugly but the fastest way to handle this without restructuring the whole GulpTask class is
         * to create sub tasks for each sub input/output pair.
         *
         * This method does exactly that.
         *
         * When a file generates a sub task, it is removed from the current task's input.
         */
        public execute(): any {
            let subTasks: GulpTask[] = [];
            let originalInputs: any = [];

            for (let i = 0; i < this.configuration.input.length; ++i) {
                for (let j = 0; j < this.configuration.input[i].files.length; ++j) {
                    let path = this.configuration.input[i].files[j];
                    if (path.isGlob && path.globBase) {
                        let indexed: {[key: string]: PackageInputOutputConfiguration} = {};
                        let files: string[] = globby.sync(path.absolute);
                        for (let k = 0; k < files.length; ++k) {
                            if (!FileSystem.isDirectory(files[k])) {
                                let relativeDir = FileSystem.getDirectoryName(files[k]).substring(path.globBase.length);
                                if (!Utils.isSet(indexed[relativeDir])) {
                                    let newInput = Utils.clone(this.configuration.input[i]);
                                    let newOutput = Utils.clone(this.configuration.output);

                                    newInput.files = [];
                                    newOutput.dev.absolute += relativeDir;
                                    newOutput.prod.absolute += relativeDir;
                                    indexed[relativeDir] = {watch: [], input: [newInput], output: newOutput};
                                }
                                indexed[relativeDir].input[0].files.push({
                                    packageId: path.packageId,
                                    original: files[k],
                                    absolute: files[k],
                                    extension: FileSystem.getExtension(files[k]),
                                    isGlob: false,
                                    globBase: ''
                                });
                            }
                        }
                        for (let p in indexed) {
                            if (indexed.hasOwnProperty(p)) {
                                subTasks.push(new MiscTask(this.gulpfile, this.packageName, indexed[p], this.processorsManager));
                            }
                        }
                        originalInputs.push(Utils.clone(this.configuration.input[i]));
                        this.configuration.input[i].files.splice(j--, 1);
                    }
                }
            }
            let stream: any = super.execute();
            this.configuration.input = originalInputs;
            for (let i = 0; i < subTasks.length; ++i) {
                const nextStream: any = subTasks[i].execute();
                if (nextStream !== null) {
                    stream = (stream !== null) ? merge(stream, nextStream) : nextStream;
                }
            }
            return stream;
        }
开发者ID:Stnaire,项目名称:gulp-yaml-packages,代码行数:75,代码来源:MiscTask.ts


示例5: join

export const getEntryAndOutput = (target: Target, command: Command) => {
  const entry: Entry = {
    index: project.ws.srcEntry
  };

  const output: StrictOutput = {
    publicPath: project.ws.publicPath,
    path: join(process.cwd(), project.ws.distDir),
    filename: '[name].js',
    // removes tabs (better for multiline strings)
    sourcePrefix: ''
  };

  // command specific config
  if (command === 'build -p') {
    output.path = join(process.cwd(), project.ws.distReleaseDir);
  } else if (command === 'unit') {
    let pattern: string[] = [];
    if (project.ws.testsPattern) {
      pattern = Array.isArray(project.ws.testsPattern)
        ? project.ws.testsPattern
        : [project.ws.testsPattern];
    }
    entry.index = globby.sync([project.ws.unitEntry, ...pattern]);
    output.path = join(process.cwd(), project.ws.distTestsDir);
  } else if (command === 'e2e') {
    entry.index = project.ws.e2eEntry;
    output.path = join(process.cwd(), project.ws.distTestsDir);
  }

  // target specific config
  if (target === 'browser') {
    output.libraryTarget = 'umd';
    output.library = project.name;
  } else if (target === 'spa') {
    output.libraryTarget = 'umd'; // is this needed?
  } else if (target === 'node') {
    const currentEntry = Array.isArray(entry.index)
      ? entry.index
      : [entry.index as string];
    entry.index = [nodeSourceMapEntry, ...currentEntry];
    output.libraryTarget = 'commonjs2';
  }

  // special cases
  if (target === 'spa' && command === 'build -p') {
    output.filename = '[name].[chunkhash].js';
    output.chunkFilename = '[name].[chunkhash].lazy.js';
  }

  return { entry, output };
};
开发者ID:Mercateo,项目名称:ws,代码行数:52,代码来源:options.ts


示例6: findMatchingFiles

  /**
   *  find matching files based on the given path or glob
   *
   * @param {string} patterns - glob pattern(s) or relative path
   * @param {boolean} [isGlob] - pass true to treat the path as a glob
   * @param {Object} [globOptions] - options to pass to globby
   * @returns {Array<string>} files
   */
  static findMatchingFiles(patterns: string | Array<string>, {isGlob, globOptions}: {
    isGlob: boolean,
    globOptions: Object,
  }): Array<string> {

    // Try to treat the patterns as globs first
    if (globby.hasMagic(patterns) || Array.isArray(patterns) || isGlob) {
      return globby.sync(patterns, globOptions);
    }

    // Fallback to the legacy implementation for non-glob patterns to avoid code breaks
    return Context.walkDirSync(patterns);
  }
开发者ID:yruan,项目名称:inceptum,代码行数:21,代码来源:Context.ts


示例7: getConfigFilePath

(() => {
  const configFilePath = getConfigFilePath();
  const workingDirectory = path.dirname(configFilePath);

  const config = require(configFilePath);

  if (config.outDir === undefined) {
    throw new Error('Invalid config: must specify an outDir.');
  }

  const sourcePaths = globby.sync(config.src, { cwd: workingDirectory })
    .map(file => path.normalize(path.join(workingDirectory, file)));

  const outputItems = generateOutput(sourcePaths, config.options);
  writeOutput(workingDirectory, config, outputItems);
})();
开发者ID:vintage-software,项目名称:vstack-typescript-generator,代码行数:16,代码来源:tsgen-cli.ts


示例8: parseContentSync

const parseAndReportFiles = (fileGlobs: string[], program: ProgramArgs): void => {
    // Get all files and their resolved globs
    const files = globby.sync(fileGlobs, {
        cwd: process.cwd(),
        ignore: program.ignore || [],
        onlyFiles: true,
        deep: true,
        unique: true,
        matchBase: true,
    });

    if (!files || !files.length) {
        console.log(logSymbols.warning, 'No files found for parsing');
        process.exit(1);
    }

    // Parallel read all of the given files
    mapLimit(
        files,
        CONCURRENCY_LIMIT,
        (file, cb) => readFile(resolve(process.cwd(), file), 'utf8', cb),
        (err, results: string[]) => {
            if (err) {
                console.log(err);
                process.exit(1);
            }
            const todos = results
                .map(function(content: string, index: number) {
                    return parseContentSync(content, program, files[index]);
                })
                // filter files without any parsed content
                .filter(item => item && item.length > 0)
                .reduce((items, item) => items.concat(item), []);

            outputTodos(todos, program);
        }
    );
};
开发者ID:pgilad,项目名称:leasot,代码行数:38,代码来源:cli.ts


示例9: sync

    ${chalk.dim('Run JPEGmini.app over every JPG in current directory')}
    imageoptim --jpegmini --no-imageoptim '**/*.jpg' '**/*.jpeg'

    ${chalk.dim('Run ImageOptim.app over every image in a specific directory')}
    imageoptim '~/Desktop'
    `.trimRight()
  );
});

program.parse(process.argv);

if (process.platform !== 'darwin') {
  console.log('imageoptim-cli is macOS only');
}

const filePaths = sync(patterns.map((pattern) => pattern.replace('~', homedir())));
const supportedFilePaths = filePaths.filter(isSupported(SUPPORTED_FILE_TYPES)).map((filePath) => ({
  source: filePath,
  tmp: join(TMPDIR, filePath)
}));

cli({
  enabled: {
    color: program.color === true,
    imageAlpha: program.imagealpha === true,
    imageOptim: program.imageoptim === true,
    jpegMini: program.jpegmini === true,
    quit: program.quit === true,
    stats: program.stats === true
  },
  files: {
开发者ID:JamieMason,项目名称:ImageOptim-CLI,代码行数:31,代码来源:imageoptim.ts


示例10: function

export default function() {
  const files: string[] = globby.sync('src/Components/AutoImport/**/*.tsx');

  log(files);
  const lib = globby.sync('types/**/*.d.ts');
  const program = ts.createProgram(files.concat(lib), compilerOptions);
  const checker = program.getTypeChecker();
  const symbol_cache = new Map<ts.Symbol, Definition>();
  // const t_cache = new WeakSet();

  const types: { type: ts.Type | null; fileName: string }[] = [];
  for (const sourceFile of program.getSourceFiles()) {
    if (
      !sourceFile.isDeclarationFile &&
      files.some(f => sourceFile.fileName.indexOf(f) > -1)
    ) {
      ts.forEachChild(sourceFile, visit);
    }
  }
  const schema = oneOf(types);
  log(JSON.stringify(schema, undefined, 2));
  return {
    code: `module.exports = {schema:${JSON.stringify(schema)}}`,
    contextDependencies: files,
    cacheable: true,
  };
  // console.log(JSON.stringify(oneOf(types), undefined, 2));

  function extractProps(node: ts.Node) {
    const typeName = node
      .getSourceFile()
      .fileName.replace(/src\/Components\/AutoImport\/(.*).tsx?/, '$1');
    const t = checker.getTypeAtLocation(node);
    if (t.isClassOrInterface()) {
      const props = checker.getTypeAtLocation(node).getProperty('props');
      if (props) {
        types.push({
          type: checker.getTypeOfSymbolAtLocation(
            props,
            props.valueDeclaration!,
          ),
          fileName: typeName,
        });
      }
    }
    const sign = checker.getSignaturesOfType(t, ts.SignatureKind.Call);
    sign.forEach(s => {
      types.push({
        type: s.parameters[0]
          ? checker.getTypeAtLocation(s.parameters[0].valueDeclaration!)
          : null,
        fileName: typeName,
      });
    });
  }
  function visit(node: ts.Node) {
    if (isNodeDefaultExported(node)) {
      extractProps(node);
      return;
    }
    if (ts.isExportAssignment(node)) {
      extractProps(node.expression);
      return;
    }
  }

  function isNodeDefaultExported(node: ts.Node): boolean {
    return (
      (ts.getCombinedModifierFlags(node as ts.Declaration) &
        ts.ModifierFlags.ExportDefault) !==
      0
    );
  }

  /*
  Types to Schema
  */
  function oneOf(
    types: { type: ts.Type | null; fileName: string }[],
  ): Definition {
    const defs: { [k: string]: Definition } = {};
    defs.components = {
      oneOf: types.map(t => {
        return {
          type: 'object',
          required: ['type', 'props'],
          properties: {
            type: {
              type: 'string',
              enum: [t.fileName],
            },
            props:
              t.type !== null
                ? serializeType(t.type)
                : { type: 'object', additionalProperties: false },
          },
        };
      }),
      defaultSnippets: [
        {
//.........这里部分代码省略.........
开发者ID:Heigvd,项目名称:Wegas,代码行数:101,代码来源:page-schema.build.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript globule.find函数代码示例发布时间:2022-05-25
下一篇:
TypeScript globby.default函数代码示例发布时间: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