Update index

Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com>
This commit is contained in:
Shakar Bakr 2023-10-04 13:52:26 +03:00
parent 204d098648
commit bac3ca6765
No known key found for this signature in database
GPG Key ID: DA55A26823AE3C28

View File

@ -53,7 +53,7 @@ async function run() {
// join the parts back together
const newVersion = versionParts.join('.');
updateProjectVersion(filePath, newVersion);
file = updateProjectVersion(filePath, newVersion);
console.log(`Old version: ${version}. New version: ${newVersion}`)
@ -100,7 +100,7 @@ async function commitChanges(file, filePath) {
const blobResponse = await axios.post(
`https://api.github.com/repos/${owner}/${repo}/git/blobs`,
{
content: file,
content: newContent,
encoding: 'utf-8',
},
{
@ -205,15 +205,19 @@ function getProjectVersion(filePath) {
}
function updateProjectVersion(filePath, newVersion) {
const projectInfoFile = require(filePath);
const projectInfoFile = getFile(filePath);
// Update the version if the file is .csproj
if (filePath.match(/\.csproj/))
projectInfoFile.Project.PropertyGroup[0].Version = newVersion;
else if (filePath.match(/package\.json/))
else if (filePath.match(/package\.json/)) {
projectInfoFile = JSON.parse(projectInfoFile)
projectInfoFile.version = newVersion;
}
return projectInfoFile;
}
function getFile(filePath) {
const file = fs.readFileSync(filePath, 'utf8');
return file;