Files
memecoin-botV2/.pnpm-store/v10/files/d3/328ef860ab752d3722792dd8b02cd5fbc619a62b3536f089ad6780a67d4b467db89b478ac0b1dea897705d641b233ae084eab55a5146739ab478cc67b5952f

22 lines
817 B
Plaintext

var cp = require('child_process');
/**
* Returns the version string of the current working directory.
* It is the git short hash of the last commit that changed filePath
* If there are uncommitted changes to this filePath, this method will throw.
* @returns {string}
*/
module.exports = function getGitHashSync(filePath) {
var commandResult;
try {
cp.execSync('git diff-index --quiet HEAD -- ' + filePath, { encoding: 'utf-8' });
} catch (err) {
//throw new Error('Cannot resolve git hash of file ' + filePath + ': There are uncommitted changes to file ' + filePath);
}
commandResult = cp.execSync('git log -n1 --pretty=format:%h -- ' + filePath, { encoding: 'utf-8' });
if (!commandResult) {
throw new Error("Could not get hash: file " + filePath + " does not exist");
}
return commandResult;
};