UNPKG

git-rev-webpack-plugin

Version:

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

27 lines 993 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runGit = void 0; var child_process_1 = require("child_process"); function runGit(cwd, command) { var gitCommand = ['git', command].join(' '); var execOptions = { stdio: ['pipe', 'pipe', 'ignore'] }; /* istanbul ignore else */ if (cwd) { execOptions.cwd = cwd; } try { child_process_1.execSync('git rev-parse --is-inside-work-tree', execOptions); var output = child_process_1.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 ''; } } exports.runGit = runGit; //# sourceMappingURL=utils.js.map