UNPKG

git-rev-webpack-plugin

Version:

Webpack plugin to use git branch, hash and tag as substitutions for file names

23 lines 835 B
import { execSync } from 'child_process'; export function runGit(cwd, command) { var gitCommand = ['git', command].join(' '); var execOptions = { stdio: ['pipe', 'pipe', 'ignore'] }; /* istanbul ignore else */ if (cwd) { execOptions.cwd = cwd; } try { execSync('git rev-parse --is-inside-work-tree', execOptions); var output = execSync(gitCommand, execOptions); return output.toString().replace(/[\s\r\n]+$/, ''); } catch (error) { /* istanbul ignore else */ if ((error === null || error === void 0 ? void 0 : error.toString().indexOf('is-inside-work-tree')) >= 0) { // eslint-disable-next-line no-console console.log('GitRevPlugin: project is not under git'); } return ''; } } //# sourceMappingURL=utils.js.map