mirror of
https://github.com/ditkrg/project-version-check.git
synced 2026-01-23 06:16:41 +00:00
Update index js
Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com>
This commit is contained in:
parent
d4671282db
commit
0f412948e4
12
index.js
12
index.js
@ -2,6 +2,7 @@ const core = require('@actions/core')
|
|||||||
const github = require('@actions/github')
|
const github = require('@actions/github')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
import convert from 'xml-js';
|
||||||
|
|
||||||
run();
|
run();
|
||||||
async function run() {
|
async function run() {
|
||||||
@ -182,10 +183,13 @@ function getProjectInfoFilePath(filePath, relativeToRoot = false) {
|
|||||||
function getProjectVersion(filePath) {
|
function getProjectVersion(filePath) {
|
||||||
const projectInfoFile = require(filePath);
|
const projectInfoFile = require(filePath);
|
||||||
|
|
||||||
// Update the version if the file is .csproj
|
if (filePath.match(/\.csproj/)) {
|
||||||
if (filePath.match(/\.csproj/))
|
|
||||||
return projectInfoFile.Project.PropertyGroup[0].Version;
|
const convertedToJson = convert.xml2js(projectInfoFile);
|
||||||
else if (filePath.match(/package\.json/))
|
// elements[0] -> PropertyGroup -> Version (object) -> text (e.g. 1.2.3)
|
||||||
|
return convertedToJson.elements[0].elements.find(el => el.name == 'PropertyGroup').elements.find(el => el.name == 'Version').elements.find(el => el.type == 'text').text;
|
||||||
|
|
||||||
|
} else if (filePath.match(/package\.json/))
|
||||||
return projectInfoFile.version;
|
return projectInfoFile.version;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user