gitlab-org--gitlab-foss/scripts/frontend/frontend_script_utils.js

26 lines
615 B
JavaScript
Raw Normal View History

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);
};
const execGitCmd = args =>
exec('git', args)
.trim()
.toString()
2018-10-22 13:47:03 -04:00
.split('\n')
.filter(Boolean);
module.exports = {
getStagedFiles: fileExtensionFilter => {
2018-03-23 12:52:54 -04:00
const gitOptions = ['diff', '--name-only', '--cached', '--diff-filter=ACMRTUB'];
if (fileExtensionFilter) gitOptions.push(...fileExtensionFilter);
return execGitCmd(gitOptions);
},
};