bluelovers
bluelovers

Reputation: 1255

nodejs child_process only get empty

when i use child_process exec/spawn for cmd

will only get '' for stdout/stderr

but it should return

$ git gc
Counting objects: 284, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (99/99), done.
Writing objects: 100% (284/284), done.
Total 284 (delta 169), reused 284 (delta 169)

$ git fsck --full
Checking object directories: 100% (256/256), done.
Checking objects: 100% (284/284), done.

what is wrong here how do i get it

Upvotes: 0

Views: 330

Answers (1)

CodeWizard
CodeWizard

Reputation: 142064

Git output to stderr and not to stdout. You have to redirect it to stdout in order to see it

git fsck --full | output.txt 2>&1

Than grab the content of the output.txt in your nodeJs application via fs.readFile...

Upvotes: 1

Related Questions