Permalink
Cannot retrieve contributors at this time
54 lines (54 sloc)
1.94 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@nodelib/fs.scandir/out/providers/sync.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0; | |
const fsStat = require("@nodelib/fs.stat"); | |
const constants_1 = require("../constants"); | |
const utils = require("../utils"); | |
const common = require("./common"); | |
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: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator) | |
}; | |
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 = common.joinPathSegments(directory, name, settings.pathSegmentSeparator); | |
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; |