refactor(types): improve vinyl types
test / test (push) Failing after 6m5s

This commit is contained in:
2026-10-27 19:24:54 +03:00
parent fc7f97b520
commit 428f9d100e
5 changed files with 58 additions and 13 deletions
+39 -7
View File
@@ -1,14 +1,46 @@
declare module "vinyl" { declare module "vinyl" {
export class File { import { type Stats } from "fs";
path: string; import type Stream from "stream";
export type Contents = Stream | Buffer | null;
export interface Options<C extends Contents = Contents> {
contents?: C;
cwd?: string;
base?: string;
path?: string;
stat?: Stats;
history?: string[];
}
export class File<C extends Contents = Contents> {
contents: C;
cwd: string; cwd: string;
base: string; base: string;
contents: any; relative: string;
stat: any; dirname: string;
history: any[]; basename: string;
constructor(params: any); stem: string;
clone(options?: any); extname: string;
path: string;
symlink: string;
stat: Stats;
history: string[];
constructor(options?: Options<C>);
isBuffer(): boolean;
isStream(): boolean;
isNull(): boolean;
isDirectory(): boolean;
isSymbolic(): boolean;
clone(options?: Options<C>);
static isCustomProp(key: string): boolean;
static isVinyl(file: File | any): boolean;
} }
export type StreamFile = File<Stream>;
export type BufferFile = File<Buffer>;
export default File; export default File;
} }
+15 -3
View File
@@ -1,10 +1,22 @@
import async from "async"; import async, { type ErrorCallback } from "async";
import child_process from "child_process"; import child_process from "child_process";
import { Logger } from "./log"; import { Logger } from "./log";
const log = new Logger("exec"); 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); log.d("*%s*", task.command);
//process.chdir(task.dir); //process.chdir(task.dir);
child_process.exec(task.command, { cwd: task.dir, maxBuffer: 1024 * 10000 }, (err, stdout, stderr) => { 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<Result> => {
return new Promise((success, failure) => { return new Promise((success, failure) => {
queue.push({ queue.push({
dir: dir, dir: dir,
+2 -1
View File
@@ -15,7 +15,8 @@ class BufferingTransform extends Transform {
callback(); callback();
} }
} }
export class TailVinyl extends Vinyl {
export class TailVinyl extends Vinyl<BufferingTransform> {
private tail?: Tail; private tail?: Tail;
constructor(params: WatchParams) { constructor(params: WatchParams) {
+1 -1
View File
@@ -18,7 +18,7 @@ export class HaxeBuilder extends Builder {
} }
prepare() { prepare() {
let result = this.haxe.prepare().then(() => this.haxe.install(this.config.libs)); let result: Promise<any> = this.haxe.prepare().then(() => this.haxe.install(this.config.libs));
if (this.buildSystem === BuildSystem.OPENFL) { if (this.buildSystem === BuildSystem.OPENFL) {
if (this.platform === Platform.ANDROID) { if (this.platform === Platform.ANDROID) {
result = result result = result
+1 -1
View File
@@ -31,7 +31,7 @@ export class Command {
this.options.env.PATH += previousPath; this.options.env.PATH += previousPath;
} }
exec(stdin?: any, callback?: any) { exec(stdin?: any, callback?: any): Vinyl<stream.Stream> {
let fileName; let fileName;
let directory; let directory;
let subShell; let subShell;