Skip to content

Commit

Permalink
Add child process log
Browse files Browse the repository at this point in the history
  • Loading branch information
HitomaruKonpaku committed Dec 1, 2024
1 parent 43a9334 commit aa795c6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,32 @@ export class Downloader {
args.push(url)
logger.verbose(`${cmd} ${args.join(' ')}`)

const spawnOptions: SpawnOptions = { detached: true, stdio: 'ignore', cwd: process.cwd() }
const spawnOptions: SpawnOptions = {
cwd: process.cwd(),
// detached: true,
// stdio: 'inherit',
}

const cp = process.platform === 'win32'
? child_process.spawn(process.env.comspec, ['/c', cmd, ...args], spawnOptions)
: child_process.spawn(cmd, args, spawnOptions)

if (cp.stdout) {
cp.stdout.setEncoding('utf8')
cp.stdout.on('data', (data) => {
const msg = data.toString()
logger.debug(msg)
})
}

if (cp.stderr) {
cp.stderr.setEncoding('utf8')
cp.stderr.on('data', (data) => {
const msg = data.toString()
logger.debug(msg)
})
}

cp.unref()
}
}

0 comments on commit aa795c6

Please sign in to comment.