@ionic/utils-fs
- Version 3.1.7
- Published
- 26.6 kB
- 4 dependencies
- MIT license
Install
npm i @ionic/utils-fs
yarn add @ionic/utils-fs
pnpm add @ionic/utils-fs
Overview
Filesystem utils for Node
Index
Functions
Classes
Interfaces
Enums
Type Aliases
Functions
function cacheFileChecksum
cacheFileChecksum: (p: string, checksum?: string) => Promise<void>;
Store a cache file containing the source file's md5 checksum hash.
Parameter p
The file path
Parameter checksum
The checksum. If excluded, the checksum is computed
function compilePaths
compilePaths: (filePath: string) => string[];
Given an absolute system path, compile an array of paths working backwards one directory at a time, always ending in the root directory.
For example,
'/some/dir'
=>['/some/dir', '/some', '/']
Parameter filePath
Absolute system base path.
function fileToString
fileToString: (filePath: string) => Promise<string>;
function findBaseDirectory
findBaseDirectory: (dir: string, file: string) => Promise<string | undefined>;
Find the base directory based on the path given and a marker file to look for.
function getFileChecksum
getFileChecksum: (filePath: string) => Promise<string>;
function getFileChecksums
getFileChecksums: (p: string) => Promise<[string, string | undefined]>;
Return true and cached checksums for a file by its path.
Cached checksums are stored as
.md5
files next to the original file. If the cache file is missing, the cached checksum is undefined.Parameter p
The file path Promise<[true checksum, cached checksum or undefined if cache file missing]>
function getFileTree
getFileTree: <RE = {}, DE = {}>( dir: string, { onError, onFileNode, onDirectoryNode, walkerOptions, }?: GetFileTreeOptions<RE, DE>) => Promise<(RegularFileNode & RE) | (DirectoryNode & DE)>;
Compile and return a file tree structure.
This function walks a directory structure recursively, building a nested object structure in memory that represents it. When finished, the root directory node is returned.
Parameter dir
The root directory from which to compile the file tree
function isExecutableFile
isExecutableFile: (filePath: string) => Promise<boolean>;
function pathAccessible
pathAccessible: (filePath: string, mode: number) => Promise<boolean>;
function pathExecutable
pathExecutable: (filePath: string) => Promise<boolean>;
function pathExists
pathExists: (filePath: string) => Promise<boolean>;
function pathReadable
pathReadable: (filePath: string) => Promise<boolean>;
function pathWritable
pathWritable: (filePath: string) => Promise<boolean>;
function readdirp
readdirp: ( dir: string, { filter, onError, walkerOptions }?: ReaddirPOptions) => Promise<string[]>;
function readdirSafe
readdirSafe: (dir: string) => Promise<string[]>;
function statSafe
statSafe: (p: string) => Promise<fs.Stats | undefined>;
function tmpfilepath
tmpfilepath: (prefix?: string) => string;
Generate a random file path within the computer's temporary directory.
Parameter prefix
Optionally provide a filename prefix.
function walk
walk: (p: string, options?: WalkerOptions) => Walker;
function writeStreamToFile
writeStreamToFile: ( stream: NodeJS.ReadableStream, destination: string) => Promise<any>;
Classes
class Walker
class Walker extends stream.Readable {}
constructor
constructor(p: string, options?: WalkerOptions);
property options
readonly options: WalkerOptions;
property p
readonly p: string;
property paths
readonly paths: string[];
Interfaces
interface DirectoryNode
interface DirectoryNode {}
interface GetFileTreeOptions
interface GetFileTreeOptions<RE = {}, DE = {}> {}
property onDirectoryNode
readonly onDirectoryNode?: (node: DirectoryNode) => DirectoryNode & DE;
Called whenever a directory node is added to the tree.
Directory nodes can be supplemented by returning a new object from this function.
property onError
readonly onError?: (err: Error) => void;
Called whenever an error occurs during the walk process.
If excluded, the function will throw an error when first encountered.
property onFileNode
readonly onFileNode?: (node: RegularFileNode) => RegularFileNode & RE;
Called whenever a file node is added to the tree.
File nodes can be supplemented by returning a new object from this function.
property walkerOptions
readonly walkerOptions?: WalkerOptions;
interface ReaddirPOptions
interface ReaddirPOptions {}
property filter
readonly filter?: (item: WalkerItem) => boolean;
Filter out items from the walk process from the final result.
true
to keep, otherwise the item is filtered out
property onError
readonly onError?: (err: Error) => void;
Called whenever an error occurs during the walk process.
If excluded, the function will throw an error when first encountered.
property walkerOptions
readonly walkerOptions?: WalkerOptions;
interface RegularFileNode
interface RegularFileNode {}
interface Walker
interface Walker extends stream.Readable {}
method on
on: { (event: 'data', callback: (item: WalkerItem) => void): this; (event: string, callback: (...args: any[]) => any): this;};
interface WalkerItem
interface WalkerItem {}
interface WalkerOptions
interface WalkerOptions {}
property pathFilter
readonly pathFilter?: (p: string) => boolean;
Filter out file paths during walk.
As the file tree is walked, this function can be used to exclude files and directories from the final result.
It can also be used to tune performance. If a subdirectory is excluded, it is not walked.
Parameter p
The file path.
true
to include file path, otherwise it is excluded
Enums
Type Aliases
type FileNode
type FileNode = RegularFileNode | DirectoryNode;
Package Files (2)
Dependencies (4)
Dev Dependencies (9)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic/utils-fs
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ionic/utils-fs)
- HTML<a href="https://www.jsdocs.io/package/@ionic/utils-fs"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3317 ms. - Missing or incorrect documentation? Open an issue for this package.