aster-src

2019-09-13

Glob files reader for aster.

aster-src

NPM versionBuild Status

Source files reader for aster.

Usage

This module is part of asterand is available via aster.src.

You use it in build scripts whenever you want to get list of files for executing build pipeline:

var aster = require('aster');

aster.src([
  '**/*.js',
  '!node_modules/**'
])
.map(plugin1(optionsForPlugin1))
.map(plugin2(optionsForPlugin2))
// ...
.subscribe(aster.runner);

aster.srcreturns Rx.Observablewhich, in order, emits single inner observable collection of file ASTs wrapped with custom {type: 'File', program: ..., loc: {source: 'fileName.js'}}node.

API

src(patterns, options)

patterns

Type: String|String[]

List of patterns as array of strings or one comma-separated string.

options

Type: Object

globmodule options (see https://github.com/isaacs/node-glob#optionsfor details).

options.noglob

Type: BooleanDefault: false

Set to true if you want patternsto be used as explicit list of files instead of globbing patterns (used by aster-watch).

options.parse

Type: Function|Boolean|ObjectDefault: true

  • If preconfigured parser (i.e., require('aster-parse-js')({loc: false})) or custom function (files) { ... }is passed, it will be used as is.
  • If boolean is passed:
    • truemeans files should be parsed with parser associated with file extension (see aster-parse).
    • falsemeans files should not be parsed and so they are pushed as {path: string, contents: string}object.
  • If object is passed, it will be used as parsing options.

src.registerParser(extension, parser)

Method for registering custom parsers associated with extension, see asterParse.registerParserfor details.

License

MIT License

Repository

asterjs/aster-src


上一篇:aster-parse
下一篇:猜代码灯谜,免费拿奖品!云开发陪你一起过中秋丨福利
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部