diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-03-17 05:52:35 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-03-17 05:52:35 +0000 |
commit | 83874edb77235d2a276f114f72942c43e8be3a44 (patch) | |
tree | 890ac40129ec2fadda1e2e3ad609cdc9a7605537 /scripts/frontend/frontend_script_utils.js | |
parent | 53e2987ba6a8b2fb79f5754ae13924f2939d81fd (diff) | |
parent | ea5221aeb358ef6c349cfa09b9c6993bd7bd027d (diff) | |
download | gitlab-ce-83874edb77235d2a276f114f72942c43e8be3a44.tar.gz |
Merge branch 'master' into 'update-kubeclient'
Conflicts:
Gemfile.lock
Diffstat (limited to 'scripts/frontend/frontend_script_utils.js')
-rw-r--r-- | scripts/frontend/frontend_script_utils.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/frontend/frontend_script_utils.js b/scripts/frontend/frontend_script_utils.js new file mode 100644 index 00000000000..2c06747255c --- /dev/null +++ b/scripts/frontend/frontend_script_utils.js @@ -0,0 +1,30 @@ +/* eslint import/no-commonjs: "off" */ +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() + .split('\n'); + +module.exports = { + getStagedFiles: fileExtensionFilter => { + const gitOptions = [ + 'diff', + '--name-only', + '--cached', + '--diff-filter=ACMRTUB', + ]; + if (fileExtensionFilter) gitOptions.push(...fileExtensionFilter); + return execGitCmd(gitOptions); + }, +}; |