diff --git a/@types/sei-helper.d.ts b/@types/sei-helper.d.ts index 740ccfb..4617d82 100644 --- a/@types/sei-helper.d.ts +++ b/@types/sei-helper.d.ts @@ -1,7 +1,6 @@ declare module 'sei-helper' { export async function question(qStr: string): Promise; export function cleanupFilename(str: string): string; - export function exec(str: string, str1: string, str2: string); export const cookie: { parse: (data: Record) => Record fs.unlinkSync(a.path)); this.options.subtitles.forEach(a => fs.unlinkSync(a.file)); diff --git a/modules/sei-helper-fixes.ts b/modules/sei-helper-fixes.ts new file mode 100644 index 0000000..112f0e8 --- /dev/null +++ b/modules/sei-helper-fixes.ts @@ -0,0 +1,28 @@ +import childProcess from 'child_process'; + +const exec = (pname: string, fpath: string, pargs: string, spc = false): { + isOk: true +} | { + isOk: false, + err: Error & { code: number } +} => { + pargs = pargs ? ' ' + pargs : ''; + console.log(`\n> "${pname}"${pargs}${spc ? '\n' : ''}`); + try { + childProcess.execSync((fpath + pargs), { stdio: 'inherit' }); + return { + isOk: true + }; + } catch (er) { + const err = er as Error & { status: number }; + return { + isOk: false, + err: { + ...err, + code: err.status + } + }; + } +}; + +export { exec }; \ No newline at end of file