2 Object.defineProperty(exports, "__esModule", { value: true });
\r
3 var path = require("path");
\r
4 var deep_1 = require("./filters/deep");
\r
5 var entry_1 = require("./filters/entry");
\r
6 var pathUtil = require("../utils/path");
\r
7 var Reader = /** @class */ (function () {
\r
8 function Reader(options) {
\r
9 this.options = options;
\r
10 this.micromatchOptions = this.getMicromatchOptions();
\r
11 this.entryFilter = new entry_1.default(options, this.micromatchOptions);
\r
12 this.deepFilter = new deep_1.default(options, this.micromatchOptions);
\r
15 * Returns root path to scanner.
\r
17 Reader.prototype.getRootDirectory = function (task) {
\r
18 return path.resolve(this.options.cwd, task.base);
\r
21 * Returns options for reader.
\r
23 Reader.prototype.getReaderOptions = function (task) {
\r
25 basePath: task.base === '.' ? '' : task.base,
\r
26 filter: this.entryFilter.getFilter(task.positive, task.negative),
\r
27 deep: this.deepFilter.getFilter(task.positive, task.negative),
\r
32 * Returns options for micromatch.
\r
34 Reader.prototype.getMicromatchOptions = function () {
\r
36 dot: this.options.dot,
\r
37 nobrace: !this.options.brace,
\r
38 noglobstar: !this.options.globstar,
\r
39 noext: !this.options.extension,
\r
40 nocase: !this.options.case,
\r
41 matchBase: this.options.matchBase
\r
45 * Returns transformed entry.
\r
47 Reader.prototype.transform = function (entry) {
\r
48 if (this.options.absolute) {
\r
49 entry.path = pathUtil.makeAbsolute(this.options.cwd, entry.path);
\r
51 if (this.options.markDirectories && entry.isDirectory()) {
\r
54 var item = this.options.stats ? entry : entry.path;
\r
55 if (this.options.transform === null) {
\r
58 return this.options.transform(item);
\r
61 * Returns true if error has ENOENT code.
\r
63 Reader.prototype.isEnoentCodeError = function (err) {
\r
64 return err.code === 'ENOENT';
\r
68 exports.default = Reader;
\r