bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
82 lines (81 loc) • 2.17 kB
TypeScript
/// <reference types="node" />
import * as fs from 'fs';
interface ConstructorOptions {
cwd?: string;
base?: string;
path?: string;
history?: string[];
stat?: fs.Stats;
contents?: Buffer | NodeJS.ReadableStream | null;
[customOption: string]: any;
}
export interface FileConstructor {
new (options: ConstructorOptions & {
contents: Buffer;
}): BufferFile;
isVinyl(obj: any): obj is File;
isCustomProp(name: string): boolean;
prototype: File;
}
declare let File: FileConstructor;
interface File {
contents: Buffer | NodeJS.ReadableStream | null;
cwd: string;
base: string;
path: string;
readonly history: ReadonlyArray<string>;
relative: string;
dirname: string;
basename: string;
stem: string;
extname: string;
symlink: string | null;
stat: fs.Stats | null;
[customProperty: string]: any;
isBuffer(): this is BufferFile;
isStream(): this is StreamFile;
isNull(): this is NullFile;
isDirectory(): this is DirectoryFile;
isSymbolic(): this is SymbolicFile;
clone(opts?: {
contents?: boolean;
deep?: boolean;
} | boolean): this;
inspect(): string;
pipe<T extends NodeJS.WritableStream>(stream: T, opts?: {
end?: boolean;
}): T;
}
interface BufferFile extends File {
contents: Buffer;
isStream(): this is never;
isBuffer(): true;
isNull(): this is never;
isDirectory(): this is never;
isSymbolic(): this is never;
}
interface StreamFile extends File {
contents: NodeJS.ReadableStream;
isStream(): true;
isBuffer(): this is never;
isNull(): this is never;
isDirectory(): this is never;
isSymbolic(): this is never;
}
interface NullFile extends File {
contents: null;
isStream(): this is never;
isBuffer(): this is never;
isNull(): true;
isDirectory(): this is DirectoryFile;
isSymbolic(): this is SymbolicFile;
}
interface DirectoryFile extends NullFile {
isDirectory(): true;
isSymbolic(): this is never;
}
interface SymbolicFile extends NullFile {
isDirectory(): this is never;
isSymbolic(): true;
}
export {};