LoginSignup
0
0

More than 5 years have passed since last update.

gitで特定フォルダ内の差分ファイル名の取得

Posted at
var exec = require('exec');

exec('cd folderName', function(){
    exec('git diff --name-only', function(err, stdout, stderr){
        if(err) throw err;
        console.log(stdout);
});

これではうまくいかなかったので調べてみたところ。
Each command is executed in a separate shell, so the first cd only affects that shell process which then terminates.
ということで、どうやら異なるシェルとして動いているためうまくいかないようです。


var exec = require('exec');

exec('git diff --name-only', {cwd: './folderName'}, function(err, stdout, stderr){
    if(err) throw err;
    console.log(stdout);
});

このように書くとうまくいきました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0