Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | const fsStat = require("@nodelib/fs.stat");
|
---|
4 | const fsWalk = require("@nodelib/fs.walk");
|
---|
5 | const reader_1 = require("./reader");
|
---|
6 | class ReaderSync extends reader_1.default {
|
---|
7 | constructor() {
|
---|
8 | super(...arguments);
|
---|
9 | this._walkSync = fsWalk.walkSync;
|
---|
10 | this._statSync = fsStat.statSync;
|
---|
11 | }
|
---|
12 | dynamic(root, options) {
|
---|
13 | return this._walkSync(root, options);
|
---|
14 | }
|
---|
15 | static(patterns, options) {
|
---|
16 | const entries = [];
|
---|
17 | for (const pattern of patterns) {
|
---|
18 | const filepath = this._getFullEntryPath(pattern);
|
---|
19 | const entry = this._getEntry(filepath, pattern, options);
|
---|
20 | if (entry === null || !options.entryFilter(entry)) {
|
---|
21 | continue;
|
---|
22 | }
|
---|
23 | entries.push(entry);
|
---|
24 | }
|
---|
25 | return entries;
|
---|
26 | }
|
---|
27 | _getEntry(filepath, pattern, options) {
|
---|
28 | try {
|
---|
29 | const stats = this._getStat(filepath);
|
---|
30 | return this._makeEntry(stats, pattern);
|
---|
31 | }
|
---|
32 | catch (error) {
|
---|
33 | if (options.errorFilter(error)) {
|
---|
34 | return null;
|
---|
35 | }
|
---|
36 | throw error;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | _getStat(filepath) {
|
---|
40 | return this._statSync(filepath, this._fsStatSettings);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | exports.default = ReaderSync;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.