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