.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / fast-glob / package / out / providers / reader.js
1 "use strict";\r
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
13     }\r
14     /**\r
15      * Returns root path to scanner.\r
16      */\r
17     Reader.prototype.getRootDirectory = function (task) {\r
18         return path.resolve(this.options.cwd, task.base);\r
19     };\r
20     /**\r
21      * Returns options for reader.\r
22      */\r
23     Reader.prototype.getReaderOptions = function (task) {\r
24         return {\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
28             sep: '/'\r
29         };\r
30     };\r
31     /**\r
32      * Returns options for micromatch.\r
33      */\r
34     Reader.prototype.getMicromatchOptions = function () {\r
35         return {\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
42         };\r
43     };\r
44     /**\r
45      * Returns transformed entry.\r
46      */\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
50         }\r
51         if (this.options.markDirectories && entry.isDirectory()) {\r
52             entry.path += '/';\r
53         }\r
54         var item = this.options.stats ? entry : entry.path;\r
55         if (this.options.transform === null) {\r
56             return item;\r
57         }\r
58         return this.options.transform(item);\r
59     };\r
60     /**\r
61      * Returns true if error has ENOENT code.\r
62      */\r
63     Reader.prototype.isEnoentCodeError = function (err) {\r
64         return err.code === 'ENOENT';\r
65     };\r
66     return Reader;\r
67 }());\r
68 exports.default = Reader;\r