From 51e454f3b17ad51d7381c0de0e4a3553bdc362d3 Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Wed, 14 Mar 2018 19:32:36 +0000 Subject: Prettier Phase 1: Prettier Configuration, Prettifying of files and documentation --- scripts/frontend/frontend_script_utils.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/frontend/frontend_script_utils.js (limited to 'scripts/frontend/frontend_script_utils.js') 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); + }, +}; -- cgit v1.2.1