Skip to content

Commit

Permalink
buffer size fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 25, 2020
1 parent 43a5270 commit 5890b3a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/server/lib/execProm.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { exec } from 'child_process';
import { exec, ExecOptions } from 'child_process';
import stripColor from 'strip-color';
import * as util from 'util';

const execProm = util.promisify(exec);
const maxBuffer = 1024 * 3000;

// tslint:disable-next-line: no-any
const exec2JSON = async (cmd: string, options = { maxBuffer }): Promise<any> => {
const exec2JSON = async (cmd: string, options?: ExecOptions): Promise<any> => {
try {
const results = await execProm(cmd, options);
return JSON.parse(stripColor(results.stdout));
const results = await execProm(cmd, { maxBuffer, ...options });
return JSON.parse(stripColor(results.stdout.toString()));
} catch (err) {
console.log(err);
return JSON.parse(stripColor(err.stdout));
}
};

// tslint:disable-next-line: no-any
const exec2String = async (cmd: string, options = { maxBuffer }): Promise<any> => {
const exec2String = async (cmd: string, options?: ExecOptions): Promise<any> => {
try {
const results = await execProm(cmd, options);
const results = await execProm(cmd, { maxBuffer, ...options });
return results.stdout;
} catch (err) {
// console.log(err);
Expand Down

0 comments on commit 5890b3a

Please sign in to comment.