feat(node-syncsub): use spawn to follow process stdout
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-03-29 23:06:56 -04:00
parent 3bc5011e6a
commit c9ded1c22d

View file

@ -1,6 +1,6 @@
import { readdir } from 'fs'; import { readdir } from 'fs';
import { ffprobe } from 'fluent-ffmpeg'; import { ffprobe } from 'fluent-ffmpeg';
import { exec } from 'child_process'; import { spawn } from 'child_process';
const SUB_EXT_LENGTH = 7; const SUB_EXT_LENGTH = 7;
@ -38,7 +38,7 @@ const main = () => {
.map((s) => s['tags']['language']); .map((s) => s['tags']['language']);
const cmd = [ const cmd = [
'subsync --cli sync', '--cli sync',
`--sub-lang ${lang}`, `--sub-lang ${lang}`,
`--ref-stream-by-lang ${availLangs.includes(lang) ? lang : other(lang)}`, `--ref-stream-by-lang ${availLangs.includes(lang) ? lang : other(lang)}`,
@ -50,12 +50,11 @@ const main = () => {
`--ref '${VIDEO}'`, `--ref '${VIDEO}'`,
// '--overwrite', // '--overwrite',
].join(' '); ];
exec(cmd, (error, stdout, stderr) => { spawn('subsync', cmd, {
console.log(error); shell: true,
console.log(stdout); stdio: [process.stdin, process.stdout, process.stderr],
console.log(stderr);
}); });
}); });
}); });