@hclsoftware/secagent
Version:
IAST agent
40 lines (36 loc) • 878 B
JavaScript
//IASTIGNORE
/*
* ****************************************************
* Licensed Materials - Property of HCL.
* (c) Copyright HCL Technologies Ltd. 2017, 2025.
* Note to U.S. Government Users *Restricted Rights.
* ****************************************************
*/
const fs = require('fs')
class PackageJsonParser
{
constructor() {
this.toReadJson = true;
}
findVersion(path)
{
if (this.toReadJson)
{
const content = fs.readFileSync(path, 'utf8');
this.json = JSON.origParse(content)
this.toReadJson = false;
}
return this.tryGetVersion()
}
tryGetVersion()
{
try {
return this.json['version'].origReplace(/[^0-9.]/g, "");
}
catch (e)
{
return null;
}
}
}
module.exports = PackageJsonParser;