Вопрос

I'd like to run a command from Node like git commit. I can do that by doing:

var exec = require("child_process").exec;
exec("git commit", function(error, stderr, stdout) {
  // Do stuff
});

However, it always hangs. I assume this is because git commit wants to take control of the console to open vim/emacs or whatever, but Node isn't allowing it. Is there a way to fix this?

Это было полезно?

Решение

Try using spawn instead of exec so you can inherit the stdio.

'use strict';

var spawn = require('child_process').spawn;
var commit = spawn('git', ['commit'], {stdio : 'inherit'});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top