2018-05-09 12:01:36 +05:30
|
|
|
const execFileSync = require('child_process').execFileSync;
|
|
|
|
|
|
|
|
const exec = (command, args) => {
|
|
|
|
const options = {
|
|
|
|
cwd: process.cwd(),
|
|
|
|
env: process.env,
|
|
|
|
encoding: 'utf-8',
|
|
|
|
};
|
|
|
|
return execFileSync(command, args, options);
|
|
|
|
};
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const execGitCmd = (args) => exec('git', args).trim().toString().split('\n').filter(Boolean);
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
module.exports = {
|
2021-03-08 18:12:59 +05:30
|
|
|
getStagedFiles: (fileExtensionFilter) => {
|
2018-05-09 12:01:36 +05:30
|
|
|
const gitOptions = ['diff', '--name-only', '--cached', '--diff-filter=ACMRTUB'];
|
|
|
|
if (fileExtensionFilter) gitOptions.push(...fileExtensionFilter);
|
|
|
|
return execGitCmd(gitOptions);
|
|
|
|
},
|
|
|
|
};
|