@file-services/types
Advanced tools
Comparing version 0.4.11 to 1.0.0
@@ -1,4 +0,5 @@ | ||
/// <reference types="node" /> | ||
import { IWatchService } from './watch-api'; | ||
import { IFileSystemPath } from './path'; | ||
import { IBaseFileSystemSync } from './base-api-sync'; | ||
import { IBaseFileSystemAsync } from './base-api-async'; | ||
export * from './base-api-sync'; | ||
export * from './base-api-async'; | ||
/** | ||
@@ -8,182 +9,4 @@ * SYNC and ASYNC base file system. | ||
*/ | ||
export interface IBaseFileSystem extends IBaseFileSystemAsync, IBaseFileSystemSync { | ||
export interface IBaseFileSystem extends IBaseFileSystemSync, IBaseFileSystemAsync { | ||
} | ||
/** | ||
* SYNC-only base file system. | ||
* Contains a subset of `fs`, watch service, and path methods. | ||
*/ | ||
export interface IBaseFileSystemSync { | ||
path: IFileSystemPath; | ||
watchService: IWatchService; | ||
caseSensitive: boolean; | ||
/** | ||
* Get the current working directory. | ||
* Non-absolute calls to any file system method are resolved using this path. | ||
* | ||
* @returns absolute path to the current working directory. | ||
*/ | ||
cwd(): string; | ||
/** | ||
* Change the working directory. | ||
* | ||
* @directoryPath path to the new working directory. | ||
*/ | ||
chdir(directoryPath: string): void; | ||
/** | ||
* Copy `sourcePath` to `destinationPath`. | ||
* By default, if destination already exists, it will be overwritten. | ||
* | ||
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists. | ||
*/ | ||
copyFileSync(sourcePath: string, destinationPath: string, flags?: number): void; | ||
/** | ||
* Read the entire contents of a file as a string. | ||
* If `encoding` isn't specified, 'utf8' is assumed. | ||
*/ | ||
readFileSync(filePath: string, encoding?: string): string; | ||
/** | ||
* Read the entire contents of a file as a Buffer. | ||
*/ | ||
readFileRawSync(filePath: string): Buffer; | ||
/** | ||
* Write data to a file, replacing the file if already exists. | ||
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8'). | ||
*/ | ||
writeFileSync(filePath: string, content: string | Buffer, encoding?: string): void; | ||
/** | ||
* Delete a name and possibly the file it refers to. | ||
*/ | ||
unlinkSync(filePath: string): void; | ||
/** | ||
* Read the names of items in a directory. | ||
*/ | ||
readdirSync(directoryPath: string): string[]; | ||
/** | ||
* Create a new directory. | ||
*/ | ||
mkdirSync(directoryPath: string): void; | ||
/** | ||
* Delete an existing directory. | ||
*/ | ||
rmdirSync(directoryPath: string): void; | ||
/** | ||
* Check if a path points to an existing file/directory/link. | ||
* | ||
* @param path possible file path. | ||
* @param statFn optional custom stat function (e.g. lstat to detect links). | ||
*/ | ||
existsSync(path: string): boolean; | ||
/** | ||
* Get path's `IFileSystemStats`. | ||
*/ | ||
statSync(path: string): IFileSystemStats; | ||
/** | ||
* Get path's `IFileSystemStats`. Does not dereference symbolic links. | ||
*/ | ||
lstatSync(path: string): IFileSystemStats; | ||
/** | ||
* Get the canonicalized absolute pathname. | ||
* If path is linked, returns the actual target path. | ||
*/ | ||
realpathSync(path: string): string; | ||
/** | ||
* Rename (move) a file or a directory | ||
*/ | ||
renameSync(sourcePath: string, destinationPath: string): void; | ||
} | ||
/** | ||
* ASYNC-only base file system. | ||
* Contains a subset of `fs`, watch service, and path methods. | ||
*/ | ||
export interface IBaseFileSystemAsync { | ||
path: IFileSystemPath; | ||
watchService: IWatchService; | ||
caseSensitive: boolean; | ||
/** | ||
* Copy `sourcePath` to `destinationPath`. | ||
* By default, if destination already exists, it will be overwritten. | ||
* | ||
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists. | ||
*/ | ||
copyFile(sourcePath: string, destinationPath: string, flags?: number): Promise<void>; | ||
/** | ||
* Read the entire contents of a file as a string. | ||
* If `encoding` isn't specified, 'utf8' is assumed. | ||
*/ | ||
readFile(filePath: string, encoding?: string): Promise<string>; | ||
/** | ||
* Read the entire contents of a file as a Buffer. | ||
*/ | ||
readFileRaw(filePath: string): Promise<Buffer>; | ||
/** | ||
* Write data to a file, replacing the file if already exists. | ||
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8'). | ||
*/ | ||
writeFile(filePath: string, content: string | Buffer, encoding?: string): Promise<void>; | ||
/** | ||
* Delete a name and possibly the file it refers to. | ||
*/ | ||
unlink(filePath: string): Promise<void>; | ||
/** | ||
* Read the names of items in a directory. | ||
*/ | ||
readdir(directoryPath: string): Promise<string[]>; | ||
/** | ||
* Create a directory. | ||
*/ | ||
mkdir(directoryPath: string): Promise<void>; | ||
/** | ||
* Delete a directory. | ||
*/ | ||
rmdir(directoryPath: string): Promise<void>; | ||
/** | ||
* Check if a path points to an existing file/directory/link. | ||
* | ||
* @param path possible file path. | ||
* @param statFn optional custom stat function (e.g. lstat to detect links). | ||
*/ | ||
exists(path: string): Promise<boolean>; | ||
/** | ||
* Get path's `IFileSystemStats`. | ||
*/ | ||
stat(path: string): Promise<IFileSystemStats>; | ||
/** | ||
* Get path's `IFileSystemStats`. Does not dereference symbolic links. | ||
*/ | ||
lstat(path: string): Promise<IFileSystemStats>; | ||
/** | ||
* Gets the canonicalized absolute pathname. | ||
* If path is linked, returns the actual target path. | ||
*/ | ||
realpath(path: string): Promise<string>; | ||
/** | ||
* Rename (move) a file or a directory | ||
*/ | ||
rename(sourcePath: string, destinationPath: string): Promise<void>; | ||
} | ||
/** | ||
* Subset of the original `fs.Stats` interface | ||
*/ | ||
export interface IFileSystemStats { | ||
/** | ||
* Creation time | ||
*/ | ||
birthtime: Date; | ||
/** | ||
* Modification time | ||
*/ | ||
mtime: Date; | ||
/** | ||
* is the path pointing to a file | ||
*/ | ||
isFile(): boolean; | ||
/** | ||
* is the path pointing to a directory | ||
*/ | ||
isDirectory(): boolean; | ||
/** | ||
* is the path pointing to a symbolic link | ||
*/ | ||
isSymbolicLink(): boolean; | ||
} | ||
//# sourceMappingURL=base-api.d.ts.map |
@@ -1,2 +0,5 @@ | ||
import { IBaseFileSystemAsync, IBaseFileSystemSync, IFileSystemStats } from './base-api'; | ||
import { IFileSystemSync } from './extended-api-sync'; | ||
import { IFileSystemAsync } from './extended-api-async'; | ||
export * from './extended-api-sync'; | ||
export * from './extended-api-async'; | ||
/** | ||
@@ -6,152 +9,4 @@ * SYNC and ASYNC file system. | ||
*/ | ||
export interface IFileSystem extends IFileSystemAsync, IFileSystemSync { | ||
export interface IFileSystem extends IFileSystemSync, IFileSystemAsync { | ||
} | ||
/** | ||
* SYNC-only file system. | ||
* Exposes all base fs APIs plus several higher level methods. | ||
*/ | ||
export interface IFileSystemSync extends IBaseFileSystemSync { | ||
/** | ||
* Check if a path points to an existing file. | ||
* | ||
* @param filePath possible file path. | ||
* @param statFn optional custom stat function (e.g. lstat to detect links). | ||
*/ | ||
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync['statSync']): boolean; | ||
/** | ||
* Check if a path points to an existing directory. | ||
* | ||
* @param directoryPath possible directory path. | ||
* @param statFn optional custom stat function (e.g. lstatSync to detect links). | ||
*/ | ||
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync['statSync']): boolean; | ||
/** | ||
* Ensure that a directory and all its parent directories exist | ||
*/ | ||
ensureDirectorySync(directoryPath: string): void; | ||
/** | ||
* Search for files inside `rootDirectory`. | ||
* | ||
* @returns absolute paths of all found files. | ||
*/ | ||
findFilesSync(rootDirectory: string, options?: IWalkOptions): string[]; | ||
/** | ||
* Search for a specific file name in parent directory chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute path of first found file, or `null` if none found. | ||
*/ | ||
findClosestFileSync(initialDirectoryPath: string, fileName: string): string | null; | ||
/** | ||
* Search for a specific file name in parent directory chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute paths of all found files (ordered from inner most directory and up). | ||
*/ | ||
findFilesInAncestorsSync(initialDirectory: string, fileName: string): string[]; | ||
/** | ||
* Populates the provided directory with given contents. | ||
* | ||
* @returns absolute paths of written files. | ||
*/ | ||
populateDirectorySync(directoryPath: string, contents: IDirectoryContents): string[]; | ||
/** | ||
* Recursively remove a path. | ||
*/ | ||
removeSync(path: string): void; | ||
} | ||
/** | ||
* ASYNC-only file system. | ||
* Exposes all base fs APIs plus several higher level methods. | ||
*/ | ||
export interface IFileSystemAsync extends IBaseFileSystemAsync { | ||
/** | ||
* Check if a path points to an existing file. | ||
* | ||
* @param filePath possible file path | ||
* @param statFn optional custom stat function (e.g. lstat to detect links) | ||
*/ | ||
fileExists(filePath: string, statFn?: IBaseFileSystemAsync['stat']): Promise<boolean>; | ||
/** | ||
* Check if a path points to an existing directory. | ||
* | ||
* @param directoryPath possible directory path | ||
* @param statFn optional custom stat function (e.g. lstatSync to detect links) | ||
*/ | ||
directoryExists(directoryPath: string, statFn?: IBaseFileSystemAsync['stat']): Promise<boolean>; | ||
/** | ||
* Ensure that a directory and all its parent directories exist | ||
*/ | ||
ensureDirectory(directoryPath: string): Promise<void>; | ||
/** | ||
* Search for files inside `rootDirectory`. | ||
* | ||
* @returns absolute paths of all found files. | ||
*/ | ||
findFiles(rootDirectory: string, options?: IWalkOptions): Promise<string[]>; | ||
/** | ||
* Search for a specific file name in parent directory chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute path of first found file, or `null` if none found. | ||
*/ | ||
findClosestFile(initialDirectoryPath: string, fileName: string): Promise<string | null>; | ||
/** | ||
* Search for a specific file name in parent chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute paths of all found files (ordered from inner most directory and up). | ||
*/ | ||
findFilesInAncestors(initialDirectory: string, fileName: string): Promise<string[]>; | ||
/** | ||
* Populates the provided directory with given contents. | ||
* | ||
* @returns absolute paths of written files. | ||
*/ | ||
populateDirectory(directoryPath: string, contents: IDirectoryContents): Promise<string[]>; | ||
/** | ||
* Recursively remove a path. | ||
*/ | ||
remove(path: string): Promise<void>; | ||
} | ||
/** | ||
* Descriptor object for an existing file system path. | ||
*/ | ||
export interface IFileSystemDescriptor { | ||
/** | ||
* Base name of the file system node. | ||
* | ||
* @example 'package.json' | ||
*/ | ||
name: string; | ||
/** | ||
* Absolute path to the file system node. | ||
* | ||
* @example '/path/to/package.json' | ||
*/ | ||
path: string; | ||
/** | ||
* Stats for the path | ||
*/ | ||
stats: IFileSystemStats; | ||
} | ||
export interface IWalkOptions { | ||
/** | ||
* Optional file filtering function that receives a file descriptor and returns | ||
* whether it should be included in the result. | ||
* | ||
* @default true returned for all files. | ||
*/ | ||
filterFile?(pathDesc: IFileSystemDescriptor): boolean; | ||
/** | ||
* Optional directory filtering function that receives a directory descriptor and returns | ||
* whether it should be walked into. | ||
* | ||
* @default true returned for all directories. | ||
*/ | ||
filterDirectory?(pathDesc: IFileSystemDescriptor): boolean; | ||
} | ||
export interface IDirectoryContents { | ||
[nodeName: string]: string | IDirectoryContents; | ||
} | ||
//# sourceMappingURL=extended-api.d.ts.map |
export * from './base-api'; | ||
export * from './constants'; | ||
export * from './common-fs-types'; | ||
export * from './extended-api'; | ||
@@ -4,0 +4,0 @@ export * from './path'; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./constants")); | ||
__export(require("./common-fs-types")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { IFileSystemStats } from './base-api'; | ||
import { IFileSystemStats } from './common-fs-types'; | ||
/** | ||
@@ -3,0 +3,0 @@ * File watching service. |
{ | ||
"name": "@file-services/types", | ||
"description": "Common file system interfaces", | ||
"version": "0.4.11", | ||
"version": "1.0.0", | ||
"main": "cjs/index.js", | ||
@@ -10,3 +10,3 @@ "types": "cjs/index.d.ts", | ||
"build": "ts-build ./src --cjs", | ||
"lint": "tslint --project src", | ||
"lint": "tslint -p src", | ||
"prepack": "yarn build" | ||
@@ -26,3 +26,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "d077e3795b175547ed2dbb821b90c12fbd29bcb5" | ||
"gitHead": "b7770933845945aa3e9fe054c4ecbfb46b0c12c9" | ||
} |
@@ -1,4 +0,7 @@ | ||
import { IWatchService } from './watch-api' | ||
import { IFileSystemPath } from './path' | ||
import { IBaseFileSystemSync } from './base-api-sync'; | ||
import { IBaseFileSystemAsync } from './base-api-async'; | ||
export * from './base-api-sync'; | ||
export * from './base-api-async'; | ||
/** | ||
@@ -8,215 +11,2 @@ * SYNC and ASYNC base file system. | ||
*/ | ||
export interface IBaseFileSystem extends IBaseFileSystemAsync, IBaseFileSystemSync {} | ||
/** | ||
* SYNC-only base file system. | ||
* Contains a subset of `fs`, watch service, and path methods. | ||
*/ | ||
export interface IBaseFileSystemSync { | ||
path: IFileSystemPath | ||
watchService: IWatchService | ||
caseSensitive: boolean | ||
/** | ||
* Get the current working directory. | ||
* Non-absolute calls to any file system method are resolved using this path. | ||
* | ||
* @returns absolute path to the current working directory. | ||
*/ | ||
cwd(): string | ||
/** | ||
* Change the working directory. | ||
* | ||
* @directoryPath path to the new working directory. | ||
*/ | ||
chdir(directoryPath: string): void | ||
/** | ||
* Copy `sourcePath` to `destinationPath`. | ||
* By default, if destination already exists, it will be overwritten. | ||
* | ||
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists. | ||
*/ | ||
copyFileSync(sourcePath: string, destinationPath: string, flags?: number): void | ||
/** | ||
* Read the entire contents of a file as a string. | ||
* If `encoding` isn't specified, 'utf8' is assumed. | ||
*/ | ||
readFileSync(filePath: string, encoding?: string): string | ||
/** | ||
* Read the entire contents of a file as a Buffer. | ||
*/ | ||
readFileRawSync(filePath: string): Buffer | ||
/** | ||
* Write data to a file, replacing the file if already exists. | ||
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8'). | ||
*/ | ||
writeFileSync(filePath: string, content: string | Buffer, encoding?: string): void | ||
/** | ||
* Delete a name and possibly the file it refers to. | ||
*/ | ||
unlinkSync(filePath: string): void | ||
/** | ||
* Read the names of items in a directory. | ||
*/ | ||
readdirSync(directoryPath: string): string[] | ||
/** | ||
* Create a new directory. | ||
*/ | ||
mkdirSync(directoryPath: string): void | ||
/** | ||
* Delete an existing directory. | ||
*/ | ||
rmdirSync(directoryPath: string): void | ||
/** | ||
* Check if a path points to an existing file/directory/link. | ||
* | ||
* @param path possible file path. | ||
* @param statFn optional custom stat function (e.g. lstat to detect links). | ||
*/ | ||
existsSync(path: string): boolean | ||
/** | ||
* Get path's `IFileSystemStats`. | ||
*/ | ||
statSync(path: string): IFileSystemStats | ||
/** | ||
* Get path's `IFileSystemStats`. Does not dereference symbolic links. | ||
*/ | ||
lstatSync(path: string): IFileSystemStats | ||
/** | ||
* Get the canonicalized absolute pathname. | ||
* If path is linked, returns the actual target path. | ||
*/ | ||
realpathSync(path: string): string | ||
/** | ||
* Rename (move) a file or a directory | ||
*/ | ||
renameSync(sourcePath: string, destinationPath: string): void | ||
} | ||
/** | ||
* ASYNC-only base file system. | ||
* Contains a subset of `fs`, watch service, and path methods. | ||
*/ | ||
export interface IBaseFileSystemAsync { | ||
path: IFileSystemPath | ||
watchService: IWatchService | ||
caseSensitive: boolean | ||
/** | ||
* Copy `sourcePath` to `destinationPath`. | ||
* By default, if destination already exists, it will be overwritten. | ||
* | ||
* @param flags passing `FileSystemConstants.COPYFILE_EXCL` will cause operation to fail if destination exists. | ||
*/ | ||
copyFile(sourcePath: string, destinationPath: string, flags?: number): Promise<void> | ||
/** | ||
* Read the entire contents of a file as a string. | ||
* If `encoding` isn't specified, 'utf8' is assumed. | ||
*/ | ||
readFile(filePath: string, encoding?: string): Promise<string> | ||
/** | ||
* Read the entire contents of a file as a Buffer. | ||
*/ | ||
readFileRaw(filePath: string): Promise<Buffer> | ||
/** | ||
* Write data to a file, replacing the file if already exists. | ||
* `encoding` is used when a string `content` (not `Buffer`) was provided (with default 'utf8'). | ||
*/ | ||
writeFile(filePath: string, content: string | Buffer, encoding?: string): Promise<void> | ||
/** | ||
* Delete a name and possibly the file it refers to. | ||
*/ | ||
unlink(filePath: string): Promise<void> | ||
/** | ||
* Read the names of items in a directory. | ||
*/ | ||
readdir(directoryPath: string): Promise<string[]> | ||
/** | ||
* Create a directory. | ||
*/ | ||
mkdir(directoryPath: string): Promise<void> | ||
/** | ||
* Delete a directory. | ||
*/ | ||
rmdir(directoryPath: string): Promise<void> | ||
/** | ||
* Check if a path points to an existing file/directory/link. | ||
* | ||
* @param path possible file path. | ||
* @param statFn optional custom stat function (e.g. lstat to detect links). | ||
*/ | ||
exists(path: string): Promise<boolean> | ||
/** | ||
* Get path's `IFileSystemStats`. | ||
*/ | ||
stat(path: string): Promise<IFileSystemStats> | ||
/** | ||
* Get path's `IFileSystemStats`. Does not dereference symbolic links. | ||
*/ | ||
lstat(path: string): Promise<IFileSystemStats> | ||
/** | ||
* Gets the canonicalized absolute pathname. | ||
* If path is linked, returns the actual target path. | ||
*/ | ||
realpath(path: string): Promise<string> | ||
/** | ||
* Rename (move) a file or a directory | ||
*/ | ||
rename(sourcePath: string, destinationPath: string): Promise<void> | ||
} | ||
/** | ||
* Subset of the original `fs.Stats` interface | ||
*/ | ||
export interface IFileSystemStats { | ||
/** | ||
* Creation time | ||
*/ | ||
birthtime: Date | ||
/** | ||
* Modification time | ||
*/ | ||
mtime: Date | ||
/** | ||
* is the path pointing to a file | ||
*/ | ||
isFile(): boolean | ||
/** | ||
* is the path pointing to a directory | ||
*/ | ||
isDirectory(): boolean | ||
/** | ||
* is the path pointing to a symbolic link | ||
*/ | ||
isSymbolicLink(): boolean | ||
} | ||
export interface IBaseFileSystem extends IBaseFileSystemSync, IBaseFileSystemAsync {} |
@@ -1,3 +0,7 @@ | ||
import { IBaseFileSystemAsync, IBaseFileSystemSync, IFileSystemStats } from './base-api' | ||
import { IFileSystemSync } from './extended-api-sync'; | ||
import { IFileSystemAsync } from './extended-api-async'; | ||
export * from './extended-api-sync'; | ||
export * from './extended-api-async'; | ||
/** | ||
@@ -7,182 +11,2 @@ * SYNC and ASYNC file system. | ||
*/ | ||
export interface IFileSystem extends IFileSystemAsync, IFileSystemSync {} | ||
/** | ||
* SYNC-only file system. | ||
* Exposes all base fs APIs plus several higher level methods. | ||
*/ | ||
export interface IFileSystemSync extends IBaseFileSystemSync { | ||
/** | ||
* Check if a path points to an existing file. | ||
* | ||
* @param filePath possible file path. | ||
* @param statFn optional custom stat function (e.g. lstat to detect links). | ||
*/ | ||
fileExistsSync(filePath: string, statFn?: IBaseFileSystemSync['statSync']): boolean | ||
/** | ||
* Check if a path points to an existing directory. | ||
* | ||
* @param directoryPath possible directory path. | ||
* @param statFn optional custom stat function (e.g. lstatSync to detect links). | ||
*/ | ||
directoryExistsSync(directoryPath: string, statFn?: IBaseFileSystemSync['statSync']): boolean | ||
/** | ||
* Ensure that a directory and all its parent directories exist | ||
*/ | ||
ensureDirectorySync(directoryPath: string): void | ||
/** | ||
* Search for files inside `rootDirectory`. | ||
* | ||
* @returns absolute paths of all found files. | ||
*/ | ||
findFilesSync(rootDirectory: string, options?: IWalkOptions): string[] | ||
/** | ||
* Search for a specific file name in parent directory chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute path of first found file, or `null` if none found. | ||
*/ | ||
findClosestFileSync(initialDirectoryPath: string, fileName: string): string | null | ||
/** | ||
* Search for a specific file name in parent directory chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute paths of all found files (ordered from inner most directory and up). | ||
*/ | ||
findFilesInAncestorsSync(initialDirectory: string, fileName: string): string[] | ||
/** | ||
* Populates the provided directory with given contents. | ||
* | ||
* @returns absolute paths of written files. | ||
*/ | ||
populateDirectorySync(directoryPath: string, contents: IDirectoryContents): string[] | ||
/** | ||
* Recursively remove a path. | ||
*/ | ||
removeSync(path: string): void | ||
/** | ||
* Recursively walk over a directory and its contents. | ||
*/ | ||
// walkSync(rootDirectory: string, options?: IWalkOptions): IFileSystemDescriptor[] | ||
} | ||
/** | ||
* ASYNC-only file system. | ||
* Exposes all base fs APIs plus several higher level methods. | ||
*/ | ||
export interface IFileSystemAsync extends IBaseFileSystemAsync { | ||
/** | ||
* Check if a path points to an existing file. | ||
* | ||
* @param filePath possible file path | ||
* @param statFn optional custom stat function (e.g. lstat to detect links) | ||
*/ | ||
fileExists(filePath: string, statFn?: IBaseFileSystemAsync['stat']): Promise<boolean> | ||
/** | ||
* Check if a path points to an existing directory. | ||
* | ||
* @param directoryPath possible directory path | ||
* @param statFn optional custom stat function (e.g. lstatSync to detect links) | ||
*/ | ||
directoryExists(directoryPath: string, statFn?: IBaseFileSystemAsync['stat']): Promise<boolean> | ||
/** | ||
* Ensure that a directory and all its parent directories exist | ||
*/ | ||
ensureDirectory(directoryPath: string): Promise<void> | ||
/** | ||
* Search for files inside `rootDirectory`. | ||
* | ||
* @returns absolute paths of all found files. | ||
*/ | ||
findFiles(rootDirectory: string, options?: IWalkOptions): Promise<string[]> | ||
/** | ||
* Search for a specific file name in parent directory chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute path of first found file, or `null` if none found. | ||
*/ | ||
findClosestFile(initialDirectoryPath: string, fileName: string): Promise<string | null> | ||
/** | ||
* Search for a specific file name in parent chain. | ||
* Useful for finding configuration or manifest files. | ||
* | ||
* @returns absolute paths of all found files (ordered from inner most directory and up). | ||
*/ | ||
findFilesInAncestors(initialDirectory: string, fileName: string): Promise<string[]> | ||
/** | ||
* Populates the provided directory with given contents. | ||
* | ||
* @returns absolute paths of written files. | ||
*/ | ||
populateDirectory(directoryPath: string, contents: IDirectoryContents): Promise<string[]> | ||
/** | ||
* Recursively remove a path. | ||
*/ | ||
remove(path: string): Promise<void> | ||
/** | ||
* Recursively walk over a directory and its contents. | ||
*/ | ||
// walk(rootDirectory: string, options?: IWalkOptions): Promise<IFileSystemDescriptor[]> | ||
} | ||
/** | ||
* Descriptor object for an existing file system path. | ||
*/ | ||
export interface IFileSystemDescriptor { | ||
/** | ||
* Base name of the file system node. | ||
* | ||
* @example 'package.json' | ||
*/ | ||
name: string | ||
/** | ||
* Absolute path to the file system node. | ||
* | ||
* @example '/path/to/package.json' | ||
*/ | ||
path: string | ||
/** | ||
* Stats for the path | ||
*/ | ||
stats: IFileSystemStats | ||
} | ||
export interface IWalkOptions { | ||
/** | ||
* Optional file filtering function that receives a file descriptor and returns | ||
* whether it should be included in the result. | ||
* | ||
* @default true returned for all files. | ||
*/ | ||
filterFile?(pathDesc: IFileSystemDescriptor): boolean | ||
/** | ||
* Optional directory filtering function that receives a directory descriptor and returns | ||
* whether it should be walked into. | ||
* | ||
* @default true returned for all directories. | ||
*/ | ||
filterDirectory?(pathDesc: IFileSystemDescriptor): boolean | ||
} | ||
export interface IDirectoryContents { | ||
[nodeName: string]: string | IDirectoryContents | ||
} | ||
export interface IFileSystem extends IFileSystemSync, IFileSystemAsync {} |
@@ -1,5 +0,5 @@ | ||
export * from './base-api' | ||
export * from './constants' | ||
export * from './extended-api' | ||
export * from './path' | ||
export * from './watch-api' | ||
export * from './base-api'; | ||
export * from './common-fs-types'; | ||
export * from './extended-api'; | ||
export * from './path'; | ||
export * from './watch-api'; |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
sep: string | ||
sep: string; | ||
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
delimiter: string | ||
delimiter: string; | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
basename(path: string, ext?: string): string | ||
basename(path: string, ext?: string): string; | ||
@@ -33,3 +33,3 @@ /** | ||
*/ | ||
dirname(path: string): string | ||
dirname(path: string): string; | ||
@@ -43,3 +43,3 @@ /** | ||
*/ | ||
extname(path: string): string | ||
extname(path: string): string; | ||
@@ -51,3 +51,3 @@ /** | ||
*/ | ||
join(...paths: string[]): string | ||
join(...paths: string[]): string; | ||
@@ -61,3 +61,3 @@ /** | ||
*/ | ||
normalize(path: string): string | ||
normalize(path: string): string; | ||
@@ -77,3 +77,3 @@ /** | ||
resolve(...pathSegments: string[]): string | ||
resolve(...pathSegments: string[]): string; | ||
@@ -85,3 +85,3 @@ /** | ||
*/ | ||
relative(from: string, to: string): string | ||
relative(from: string, to: string): string; | ||
@@ -94,3 +94,3 @@ /** | ||
*/ | ||
isAbsolute(path: string): boolean | ||
isAbsolute(path: string): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { IFileSystemStats } from './base-api' | ||
import { IFileSystemStats } from './common-fs-types'; | ||
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
watchPath(path: string, listener?: WatchEventListener): Promise<void> | ||
watchPath(path: string, listener?: WatchEventListener): Promise<void>; | ||
@@ -21,3 +21,3 @@ /** | ||
*/ | ||
unwatchPath(path: string, listener?: WatchEventListener): Promise<void> | ||
unwatchPath(path: string, listener?: WatchEventListener): Promise<void>; | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
unwatchAllPaths(): Promise<void> | ||
unwatchAllPaths(): Promise<void>; | ||
@@ -34,3 +34,3 @@ /** | ||
*/ | ||
addGlobalListener(listener: WatchEventListener): void | ||
addGlobalListener(listener: WatchEventListener): void; | ||
@@ -40,3 +40,3 @@ /** | ||
*/ | ||
removeGlobalListener(listener: WatchEventListener): void | ||
removeGlobalListener(listener: WatchEventListener): void; | ||
@@ -46,3 +46,3 @@ /** | ||
*/ | ||
clearGlobalListeners(): void | ||
clearGlobalListeners(): void; | ||
} | ||
@@ -55,4 +55,4 @@ | ||
export interface IWatchEvent { | ||
path: string | ||
stats: IFileSystemStats | null | ||
path: string; | ||
stats: IFileSystemStats | null; | ||
} | ||
@@ -63,2 +63,2 @@ | ||
*/ | ||
export type WatchEventListener = (watchEvent: IWatchEvent) => void | ||
export type WatchEventListener = (watchEvent: IWatchEvent) => void; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
62776
53
1289
0
1