Sha256: 5296d2103bbaea6e3ec5c07e1233f77b3868757ce3ed9f3ff9d51a1a2ad8675d

Contents?: true

Size: 1.87 KB

Versions: 51

Compression:

Stored size: 1.87 KB

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fsScandir = require("@nodelib/fs.scandir");
const common = require("./common");
const reader_1 = require("./reader");
class SyncReader extends reader_1.default {
    constructor() {
        super(...arguments);
        this._scandir = fsScandir.scandirSync;
        this._storage = [];
        this._queue = new Set();
    }
    read() {
        this._pushToQueue(this._root, this._settings.basePath);
        this._handleQueue();
        return this._storage;
    }
    _pushToQueue(directory, base) {
        this._queue.add({ directory, base });
    }
    _handleQueue() {
        for (const item of this._queue.values()) {
            this._handleDirectory(item.directory, item.base);
        }
    }
    _handleDirectory(directory, base) {
        try {
            const entries = this._scandir(directory, this._settings.fsScandirSettings);
            for (const entry of entries) {
                this._handleEntry(entry, base);
            }
        }
        catch (error) {
            this._handleError(error);
        }
    }
    _handleError(error) {
        if (!common.isFatalError(this._settings, error)) {
            return;
        }
        throw error;
    }
    _handleEntry(entry, base) {
        const fullpath = entry.path;
        if (base !== undefined) {
            entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
        }
        if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
            this._pushToStorage(entry);
        }
        if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
            this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
        }
    }
    _pushToStorage(entry) {
        this._storage.push(entry);
    }
}
exports.default = SyncReader;

Version data entries

51 entries across 51 versions & 3 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.59 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.58 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.57 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.56 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.55 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.54 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.53 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.52 node_modules/@nodelib/fs.walk/out/readers/sync.js
trusty-cms-6.3.1 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.51 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.50 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.49 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.48 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.47 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.46 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.45 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.44 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.43 node_modules/@nodelib/fs.walk/out/readers/sync.js
immosquare-cleaner-0.1.42 node_modules/@nodelib/fs.walk/out/readers/sync.js