node.js child_process git clone在atom中的密码input

我想克隆一个git仓库,在我的atom包中需要node.js的child_process模块​​:

var spawn = require('child_process').spawn; var gitClone = spawn('git', ['clone', 'ssh://user@gitrepo.com/path/to/reponame'], {cwd: path}); gitClone.stdout.on('data', (data) => { gitClone.stdin.write('password'); console.log(`stdout: ${data}`); }); gitClone.stderr.on('data', (data) => { console.log(`stderr: ${data}`); }); gitClone.on('close', (code) => { console.log(`child process exited with code ${code}`); }); 

由于无法使用ssh密钥,所以我需要将用户的密码传递给派生进程。

我想关于这个话题也可以解决我的问题,但似乎没有进入我的gitClone.stdout.on('data', function (data) { ... }的可能性。任何console.log()我试图从那里执行,不会显示在Chrome引擎的控制台上。

这是我的输出:

  stderr: Cloning into 'reponame'... stderr: Permission denied, please try again. stderr: Permission denied, please try again. stderr: Permission denied (publickey,password). stderr: fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. child process exited with code 128 

我想知道为什么我只能看到sdterr消息。 当我在我的bash中运行git clone ,它首先会告诉我Cloning into 'reponame'... ,然后它会要求input密码。

有没有办法赶上child_process的spawn()的密码提示?