Sha256: 98ca6b7caa8d7fa1d7e15ad82f197a9189d8d265438b9f53e1cb2748d03d9390

Contents?: true

Size: 1.85 KB

Versions: 23

Compression:

Stored size: 1.85 KB

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fsStat = require("@nodelib/fs.stat");
const constants_1 = require("../constants");
const utils = require("../utils");
function read(directory, settings) {
    if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
        return readdirWithFileTypes(directory, settings);
    }
    return readdir(directory, settings);
}
exports.read = read;
function readdirWithFileTypes(directory, settings) {
    const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
    return dirents.map((dirent) => {
        const entry = {
            dirent,
            name: dirent.name,
            path: `${directory}${settings.pathSegmentSeparator}${dirent.name}`
        };
        if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
            try {
                const stats = settings.fs.statSync(entry.path);
                entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
            }
            catch (error) {
                if (settings.throwErrorOnBrokenSymbolicLink) {
                    throw error;
                }
            }
        }
        return entry;
    });
}
exports.readdirWithFileTypes = readdirWithFileTypes;
function readdir(directory, settings) {
    const names = settings.fs.readdirSync(directory);
    return names.map((name) => {
        const entryPath = `${directory}${settings.pathSegmentSeparator}${name}`;
        const stats = fsStat.statSync(entryPath, settings.fsStatSettings);
        const entry = {
            name,
            path: entryPath,
            dirent: utils.fs.createDirentFromStats(name, stats)
        };
        if (settings.stats) {
            entry.stats = stats;
        }
        return entry;
    });
}
exports.readdir = readdir;

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.6 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.5 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.4 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.3 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.2 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.1 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.3.5 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-5.0.0 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.3.4 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.3.3 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.3.2 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.3.1 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.3 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.2.3 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.2.2 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.2.1 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.2 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.1.9 node_modules/@nodelib/fs.scandir/out/providers/sync.js
trusty-cms-4.1.8 node_modules/@nodelib/fs.scandir/out/providers/sync.js