title: How can I handle an input prompt with node when executing a command via child_process?
body: <p>For context, I'm on a Mac and I'm trying to script a 1Password CLI signin via their <a href="https://support.1password.com/command-line/" rel="nofollow noreferrer">command-line tool</a>. I'm trying to programmatically signing using a command that looks like:</p>
  
  <pre><code>op signin &lt;signinaddress&gt; &lt;emailaddress&gt; &lt;secretkey&gt; --output=raw
  </code></pre>
  
  <p>and I've tried with/without the --output=raw argument, but every time I simply get an error that looks like</p>
  
  <pre><code>[LOG] 2019/06/04 00:57:45 (ERROR) operation not supported on socket
  
  child process exited with code 1
  </code></pre>
  
  <p>My initial hunch was that it had something to do with the command executions prompt displaying this special key character in the following image:</p>
  
  <p><a href="https://i.stack.imgur.com/bHJy4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bHJy4.png" alt="op signin prompt img"></a></p>
  
  <p>The relevant code is written in TypeScript and looks like this:</p>
  
  <pre><code>import { spawn } from 'child_process'
  
  // ends up being `op signin &lt;signinaddress&gt; &lt;emailaddress&gt; &lt;secretkey&gt;`
  const op = spawn(opExecutable, args);
  let result: string | null = null
  
  op.on('message', (message, sendHandle) =&gt; {
    console.log('message', message, sendHandle)
  });
  op.stdout.on('data', (data) =&gt; {
    console.log(`stdout: ${data}`);
    if (data &amp;&amp; typeof data.toString === 'function') {
      result = data.toString()
    }
  });
  
  op.on('close', (code, ...args) =&gt; {
    console.log(`child process exited with code ${code}`, args);
  });
  </code></pre>
  
  <p>Eventually, I'd like to run on all platforms and be able pass in stdin for the master password required to sign in, but I'm trying to figure out why my node app is crashing first :)</p>