diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2018-03-14 19:32:36 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-03-14 19:32:36 +0000 |
commit | 51e454f3b17ad51d7381c0de0e4a3553bdc362d3 (patch) | |
tree | 798f833d9ac8f253eab28f449931fca51d063867 /scripts/frontend/frontend_script_utils.js | |
parent | d22e7a421eb323e878a86de36a42aab56c2c53ed (diff) | |
download | gitlab-ce-51e454f3b17ad51d7381c0de0e4a3553bdc362d3.tar.gz |
Prettier Phase 1: Prettier Configuration, Prettifying of files and documentation
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); + }, +}; |