multi-downloader-nx/modules/sei-helper-fixes.ts
AnimeDL b491ba1917 Fix command line length issue
Fixes long standing issue on windows where if the command line length was over 8191 characters, this was achieved by switching node.exec to use powershell.exe instead of cmd.exe on Windows
2024-01-29 22:49:10 -08:00

33 lines
No EOL
807 B
TypeScript

import childProcess from 'child_process';
import { console } from './log';
const exec = (pname: string, fpath: string, pargs: string, spc = false): {
isOk: true
} | {
isOk: false,
err: Error & { code: number }
} => {
pargs = pargs ? ' ' + pargs : '';
console.info(`\n> "${pname}"${pargs}${spc ? '\n' : ''}`);
try {
if (process.platform === 'win32') {
childProcess.execSync(('& ' + fpath + pargs), { stdio: 'inherit', 'shell': 'powershell.exe', 'windowsHide': true });
} else {
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 };