UNPKG

@stryke/fs

Version:

A package containing various file system utilities that expand the functionality of NodeJs's built-in `fs` module.

64 lines (62 loc) 2.64 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('./_virtual/_rolldown/runtime.cjs'); let node_fs = require("node:fs"); let _stryke_path_join_paths = require("@stryke/path/join-paths"); //#region src/is-file.ts var is_file_exports = /* @__PURE__ */ require_runtime.__exportAll({ isDirectory: () => isDirectory, isDirectorySymlink: () => isDirectorySymlink, isFile: () => isFile, isFileSymlink: () => isFileSymlink }); /** * Check if the given path is a file. * * @param path - The location to check * @param additionalPath - An optional additional path to add to the start of the path * @returns An indicator specifying if the path is a file */ function isFile(path, additionalPath) { return Boolean((0, node_fs.statSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile()); } /** * Check if the given path is a directory. * * @param path - The location to check * @param additionalPath - An optional additional path to add to the start of the path * @returns An indicator specifying if the path is a directory */ function isDirectory(path, additionalPath) { return Boolean((0, node_fs.statSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory()); } /** * Check if the given path is a file . Does not dereference symbolic links. * * @param path - The location to check * @param additionalPath - An optional additional path to add to the start of the path * @returns An indicator specifying if the path is a file */ const isFileSymlink = (path, additionalPath) => { return Boolean((0, node_fs.lstatSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile()); }; /** * Check if the given path is a directory. Does not dereference symbolic links. * * @param path - The location to check * @param additionalPath - An optional additional path to add to the start of the path * @returns An indicator specifying if the path is a directory */ const isDirectorySymlink = (path, additionalPath) => { return Boolean((0, node_fs.lstatSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory()); }; //#endregion exports.isDirectory = isDirectory; exports.isDirectorySymlink = isDirectorySymlink; exports.isFile = isFile; exports.isFileSymlink = isFileSymlink; Object.defineProperty(exports, 'is_file_exports', { enumerable: true, get: function () { return is_file_exports; } });