source: trip-planner-front/node_modules/@nodelib/fs.scandir/out/providers/sync.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
4const fsStat = require("@nodelib/fs.stat");
5const constants_1 = require("../constants");
6const utils = require("../utils");
7const common = require("./common");
8function read(directory, settings) {
9 if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
10 return readdirWithFileTypes(directory, settings);
11 }
12 return readdir(directory, settings);
13}
14exports.read = read;
15function readdirWithFileTypes(directory, settings) {
16 const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
17 return dirents.map((dirent) => {
18 const entry = {
19 dirent,
20 name: dirent.name,
21 path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
22 };
23 if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
24 try {
25 const stats = settings.fs.statSync(entry.path);
26 entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
27 }
28 catch (error) {
29 if (settings.throwErrorOnBrokenSymbolicLink) {
30 throw error;
31 }
32 }
33 }
34 return entry;
35 });
36}
37exports.readdirWithFileTypes = readdirWithFileTypes;
38function readdir(directory, settings) {
39 const names = settings.fs.readdirSync(directory);
40 return names.map((name) => {
41 const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
42 const stats = fsStat.statSync(entryPath, settings.fsStatSettings);
43 const entry = {
44 name,
45 path: entryPath,
46 dirent: utils.fs.createDirentFromStats(name, stats)
47 };
48 if (settings.stats) {
49 entry.stats = stats;
50 }
51 return entry;
52 });
53}
54exports.readdir = readdir;
Note: See TracBrowser for help on using the repository browser.