« get me outta code hell

Fix the spooky youtube-dl problem - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/promisify-process.js
diff options
context:
space:
mode:
authorliam4 <towerofnix@gmail.com>2017-06-04 17:09:04 -0300
committerliam4 <towerofnix@gmail.com>2017-06-04 17:09:04 -0300
commit9fb775446f151b492f17bd42b757b958f5ea3fa0 (patch)
treebdbcf253ec286341802347e81a3ffa374817e336 /src/promisify-process.js
parentfbdbed0c46bfc947e66f1896799bfdc614b46524 (diff)
Fix the spooky youtube-dl problem
Diffstat (limited to 'src/promisify-process.js')
-rw-r--r--src/promisify-process.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/promisify-process.js b/src/promisify-process.js
index ef8d0c6..4d06f8c 100644
--- a/src/promisify-process.js
+++ b/src/promisify-process.js
@@ -1,5 +1,7 @@
 'use strict'
 
+const { Writable } = require('stream')
+
 module.exports = function promisifyProcess(proc, showLogging = true) {
   // Takes a process (from child_process) and returns a promise that resolves
   // when the process exits (or rejects with a warning, if the exit code is
@@ -9,6 +11,16 @@ module.exports = function promisifyProcess(proc, showLogging = true) {
     if (showLogging) {
       proc.stdout.pipe(process.stdout)
       proc.stderr.pipe(process.stderr)
+    } else {
+      // For some mysterious reason, youtube-dl doesn't seem to work unless
+      // we pipe the output of it SOMEWHERE..
+
+      const emptyStream = () => Object.assign(new Writable(), {
+        write: () => {}
+      })
+
+      proc.stdout.pipe(emptyStream())
+      proc.stderr.pipe(emptyStream())
     }
 
     proc.on('exit', code => {