diff --git a/src/@types/vinyl.d.ts b/src/@types/vinyl.d.ts index b4577cc..2bdbaa4 100644 --- a/src/@types/vinyl.d.ts +++ b/src/@types/vinyl.d.ts @@ -1,14 +1,46 @@ declare module "vinyl" { - export class File { - path: string; + import { type Stats } from "fs"; + import type Stream from "stream"; + + export type Contents = Stream | Buffer | null; + + export interface Options { + contents?: C; + cwd?: string; + base?: string; + path?: string; + stat?: Stats; + history?: string[]; + } + + export class File { + contents: C; cwd: string; base: string; - contents: any; - stat: any; - history: any[]; - constructor(params: any); - clone(options?: any); + relative: string; + dirname: string; + basename: string; + stem: string; + extname: string; + path: string; + symlink: string; + stat: Stats; + history: string[]; + + constructor(options?: Options); + isBuffer(): boolean; + isStream(): boolean; + isNull(): boolean; + isDirectory(): boolean; + isSymbolic(): boolean; + clone(options?: Options); + + static isCustomProp(key: string): boolean; + static isVinyl(file: File | any): boolean; } + export type StreamFile = File; + export type BufferFile = File; + export default File; } diff --git a/src/common/exec.ts b/src/common/exec.ts index cee9bc8..9e77035 100755 --- a/src/common/exec.ts +++ b/src/common/exec.ts @@ -1,10 +1,22 @@ -import async from "async"; +import async, { type ErrorCallback } from "async"; import child_process from "child_process"; import { Logger } from "./log"; const log = new Logger("exec"); -const queue = async.queue((task: any, done: any) => { +export interface Result { + stdout: string; + stderr: string; +} + +interface Task { + dir: string; + command: string; + success: (result: Result) => void; + failure: (error: string) => void; +} + +const queue = async.queue((task: Task, done: ErrorCallback) => { log.d("*%s*", task.command); //process.chdir(task.dir); child_process.exec(task.command, { cwd: task.dir, maxBuffer: 1024 * 10000 }, (err, stdout, stderr) => { @@ -19,7 +31,7 @@ const queue = async.queue((task: any, done: any) => { }); }); -export default (dir: string, command: string) => { +export default (dir: string, command: string): Promise => { return new Promise((success, failure) => { queue.push({ dir: dir, diff --git a/src/common/watch.ts b/src/common/watch.ts index aedbf05..6a92e4b 100644 --- a/src/common/watch.ts +++ b/src/common/watch.ts @@ -15,7 +15,8 @@ class BufferingTransform extends Transform { callback(); } } -export class TailVinyl extends Vinyl { + +export class TailVinyl extends Vinyl { private tail?: Tail; constructor(params: WatchParams) { diff --git a/src/project/impl/builder/haxe.ts b/src/project/impl/builder/haxe.ts index 331c98e..1519dd3 100644 --- a/src/project/impl/builder/haxe.ts +++ b/src/project/impl/builder/haxe.ts @@ -18,7 +18,7 @@ export class HaxeBuilder extends Builder { } prepare() { - let result = this.haxe.prepare().then(() => this.haxe.install(this.config.libs)); + let result: Promise = this.haxe.prepare().then(() => this.haxe.install(this.config.libs)); if (this.buildSystem === BuildSystem.OPENFL) { if (this.platform === Platform.ANDROID) { result = result diff --git a/src/run/command.ts b/src/run/command.ts index c191b26..c89575a 100644 --- a/src/run/command.ts +++ b/src/run/command.ts @@ -31,7 +31,7 @@ export class Command { this.options.env.PATH += previousPath; } - exec(stdin?: any, callback?: any) { + exec(stdin?: any, callback?: any): Vinyl { let fileName; let directory; let subShell;