makit
Version:
Make in JavaScript done right!
53 lines (52 loc) • 2.2 kB
TypeScript
/// <reference types="node" />
import { MakeDirectoryOptions } from 'fs';
import { Logger } from './utils/logger';
import { FileSystem } from './fs/file-system';
import { TimeStamp } from './fs/time-stamp';
interface ContextOptions {
target: string;
match: RegExpExecArray | null;
root: string;
fs: FileSystem;
make: (target: string) => Promise<TimeStamp>;
}
export declare class Context implements FileSystem {
readonly target: string;
readonly match: RegExpExecArray | null;
dependencies: string[];
dynamicDependencies: string[];
logger: Logger;
private readonly makeImpl;
private readonly fs;
private readonly root;
constructor({ target, match, root, fs, make }: ContextOptions);
make(target: string): Promise<number>;
outputFile(filepath: string, content: string | Buffer): Promise<void>;
outputFileSync(filepath: string, content: string | Buffer): void;
readDependency(i?: number): Promise<string>;
readDependencySync(i?: number): string;
targetFullPath(): string;
targetPath(): string;
dependencyFullPath(i?: number): string;
dependencyPath(i?: number): string;
writeTarget(content: string): Promise<void>;
writeTargetSync(content: string): void;
toFullPath(filename: string): string;
/**
* FileSystem Implements
*/
mkdir(filepath: string, options?: number | string | MakeDirectoryOptions | null): Promise<void>;
mkdirSync(filepath: string, options: number | string | MakeDirectoryOptions | null): void;
writeFile(filepath: string, content: string | Buffer): Promise<void>;
writeFileSync(filepath: string, content: string | Buffer): void;
readFile(filepath: string, encoding?: string): Promise<string>;
readFileSync(filepath: string, encoding: string): string;
unlinkSync(filepath: string): void;
unlink(filepath: string): Promise<void>;
existsSync(filepath: string): boolean;
utimes(filepath: string, atime: number, utime: number): Promise<void>;
utimesSync(filepath: string, atime: number, utime: number): void;
stat(filepath: string): Promise<import("fs").Stats>;
statSync(filepath: string): import("fs").Stats;
}
export {};