This commit is contained in:
+15
-3
@@ -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<Result> => {
|
||||
return new Promise((success, failure) => {
|
||||
queue.push({
|
||||
dir: dir,
|
||||
|
||||
+2
-1
@@ -15,7 +15,8 @@ class BufferingTransform extends Transform {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
export class TailVinyl extends Vinyl {
|
||||
|
||||
export class TailVinyl extends Vinyl<BufferingTransform> {
|
||||
private tail?: Tail;
|
||||
|
||||
constructor(params: WatchParams) {
|
||||
|
||||
Reference in New Issue
Block a user