UNPKG

mangle-version

Version:
21 lines 924 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.modifyPackageJsonSYNC = exports.detectGitCommitSHA = void 0; const tslib_1 = require("tslib"); const fs_1 = require("fs"); const path_1 = require("path"); const promise_1 = (0, tslib_1.__importDefault)(require("simple-git/promise")); async function detectGitCommitSHA(dir) { const git = (0, promise_1.default)(dir); const sha = await git.revparse(['--verify', 'HEAD']); return sha; } exports.detectGitCommitSHA = detectGitCommitSHA; function modifyPackageJsonSYNC(dir, version) { const filePath = (0, path_1.resolve)(dir, 'package.json'); const pkg = JSON.parse((0, fs_1.readFileSync)(filePath, 'utf-8')); pkg.version = version; (0, fs_1.writeFileSync)(filePath, JSON.stringify(pkg, undefined, ' ') + '\n'); } exports.modifyPackageJsonSYNC = modifyPackageJsonSYNC; //# sourceMappingURL=version-mangler.js.map