@lakutata/core
Version:
Lakutata Framework Core
163 lines (162 loc) • 6.04 kB
TypeScript
/// <reference types="node" />
import child = require('child_process');
export interface TouchOptionsArray {
'-d'?: string | undefined;
'-r'?: string | undefined;
}
export interface ExecOutputReturnValue {
code: number;
stdout: string;
stderr: string;
}
export interface ShellReturnValue extends ExecOutputReturnValue {
to(file: string): void;
toEnd(file: string): void;
cat: CatFunction;
exec: ExecFunction;
head: HeadFunction;
grep: GrepFunction;
sed: SedFunction;
sort: SortFunction;
tail: TailFunction;
uniq: UniqFunction;
}
export interface TailOptions {
'-n': number;
}
export interface TailFunction {
(options: TailOptions, files: string[]): ShellString;
(options: TailOptions, ...files: string[]): ShellString;
(files: string[]): ShellString;
(...files: string[]): ShellString;
}
export interface SortFunction {
(options: string, files: string[]): ShellString;
(options: string, ...files: string[]): ShellString;
(files: string[]): ShellString;
(...files: string[]): ShellString;
}
export interface TouchFunction {
(options: TouchOptionsLiteral | TouchOptionsArray, files: string[]): ShellString;
(options: TouchOptionsLiteral | TouchOptionsArray, ...files: string[]): ShellString;
(files: string[]): ShellString;
(...files: string[]): ShellString;
}
export interface UniqFunction {
(options: string, input: string, output?: string): ShellString;
(input: string, output?: string): ShellString;
}
export interface SedFunction {
(options: string, searchRegex: string | RegExp, replacement: string, files: string[]): ShellString;
(options: string, searchRegex: string | RegExp, replacement: string, ...files: string[]): ShellString;
(searchRegex: string | RegExp, replacement: string, files: string[]): ShellString;
(searchRegex: string | RegExp, replacement: string, ...files: string[]): ShellString;
}
export interface RemoveFunction {
(options: string, files: string[]): ShellString;
(options: string, ...files: string[]): ShellString;
(files: string[]): ShellString;
(...files: string[]): ShellString;
}
export interface PushDirFunction {
(options: string, dir: '+N'): ShellArray;
(options: string, dir: '-N'): ShellArray;
(options: string, dir: string): ShellArray;
(dir: '+N'): ShellArray;
(dir: '-N'): ShellArray;
(dir: string): ShellArray;
(): ShellArray;
}
export interface PopDirFunction {
(options: string, dir: '+N'): ShellArray;
(options: string, dir: '-N'): ShellArray;
(options: string, dir: string): ShellArray;
(dir: '+N'): ShellArray;
(dir: '-N'): ShellArray;
(dir: string): ShellArray;
(): ShellArray;
}
export interface MoveFunction {
(options: string, source: string | string[], dest: string): ShellString;
(source: string | string[], dest: string): ShellString;
}
export interface MkdirFunction {
(options: string, dir: string[]): ShellString;
(options: string, ...dir: string[]): ShellString;
(dir: string[]): ShellString;
(...dir: string[]): ShellString;
}
export interface ListFunction {
(options: string, paths: string[]): ShellArray;
(options: string, ...paths: string[]): ShellArray;
(paths: string[]): ShellArray;
(...paths: string[]): ShellArray;
}
export interface LinkFunction {
(options: string, source: string, dest: string): ShellString;
(source: string, dest: string): ShellString;
}
export interface HeadOptions {
'-n': number;
}
export interface HeadFunction {
(options: HeadOptions, files: string[]): ShellString;
(options: HeadOptions, ...files: string[]): ShellString;
(files: string[]): ShellString;
(...files: string[]): ShellString;
}
export interface GrepFunction {
(options: string, regex_filter: string | RegExp, files: string[]): ShellString;
(options: string, regex_filter: string | RegExp, ...files: string[]): ShellString;
(regex_filter: string | RegExp, files: string[]): ShellString;
(regex_filter: string | RegExp, ...files: string[]): ShellString;
}
export interface FindFunction {
(path: string[]): ShellArray;
(...path: string[]): ShellArray;
}
export interface ExecOptions extends child.ExecOptions {
silent?: boolean | undefined;
fatal?: boolean | undefined;
async?: boolean | undefined;
encoding?: string | undefined;
}
export interface ExecFunction {
(command: string): ShellString;
(command: string, options: ExecOptions & {
async?: false | undefined;
}): ShellString;
(command: string, options: ExecOptions & {
async: true;
}): child.ChildProcess;
(command: string, options: ExecOptions): ShellString | child.ChildProcess;
(command: string, options: ExecOptions, callback: ExecCallback): child.ChildProcess;
(command: string, callback: ExecCallback): child.ChildProcess;
}
export interface EchoFunction {
(options: string, ...text: string[]): ShellString;
(...text: string[]): ShellString;
}
export interface DirsFunction {
(options: '-c'): ShellArray;
(options: '+N'): ShellString;
(options: '-N'): ShellString;
(options: string): ShellArray | ShellString;
}
export interface CopyFunction {
(options: string, source: string | string[], dest: string): ShellString;
(source: string | string[], dest: string): ShellString;
}
export interface CatFunction {
(files: string[]): ShellString;
(...files: string[]): ShellString;
}
export interface ChmodFunction {
(options: string, mode: string | number, file: string): ShellString;
(mode: string | number, file: string): ShellString;
}
export declare type ExecCallback = (code: number, stdout: string, stderr: string) => any;
export declare type ShellArray = string[] & ShellReturnValue;
export declare type TestOptions = '-b' | '-c' | '-d' | '-e' | '-f' | '-L' | '-p' | '-S';
export declare type ShellString = string & ShellReturnValue;
export declare type TouchOptionsLiteral = '-a' | '-c' | '-m' | '-d' | '-r';