mirror of
https://github.com/ditkrg/project-version-check.git
synced 2026-01-22 22:06:42 +00:00
Update filePath functionality
Signed-off-by: Shakar <5h4k4r.b4kr@gmail.com>
This commit is contained in:
parent
495b125338
commit
2303020aad
12
index.js
12
index.js
@ -49,8 +49,8 @@ async function run() {
|
||||
console.log(`Old version: ${version}. New version: ${newVersion}`)
|
||||
|
||||
// fs.writeFileSync(file, JSON.stringify(file, null, 2));
|
||||
|
||||
await commitChanges(core.getInput('filePath'), file);
|
||||
const filePathRelatedToRoot = getProjectInfoFilePath(filePathInput, true);
|
||||
await commitChanges(file, filePathRelatedToRoot);
|
||||
|
||||
const payload = JSON.stringify(github.context.payload, undefined, 2)
|
||||
|
||||
@ -62,7 +62,7 @@ async function run() {
|
||||
|
||||
|
||||
// Region functions
|
||||
async function commitChanges(filePath, file) {
|
||||
async function commitChanges(file, filePath) {
|
||||
const commitMessage = 'Commit message here';
|
||||
const newContent = file;
|
||||
const githubToken = core.getInput('githubToken');
|
||||
@ -165,16 +165,16 @@ async function commitChanges(filePath, file) {
|
||||
}
|
||||
}
|
||||
|
||||
function getProjectInfoFilePath(filePath) {
|
||||
function getProjectInfoFilePath(filePath, relativeToRoot = false) {
|
||||
if (filePath == null || filePath == undefined || filePath == '') {
|
||||
// List files inside the root directory of the repository
|
||||
const files = fs.readdirSync(process.cwd());
|
||||
// Return the first file that matches .csproj or package.json
|
||||
const projectInfoFile = files.find(file => file.match(/\.csproj|package\.json/));
|
||||
return `${process.cwd()}/${projectInfoFile}`;
|
||||
return relativeToRoot ? projectInfoFile : `${process.cwd()}/${projectInfoFile}`;
|
||||
}
|
||||
else
|
||||
return `${process.cwd()}/${filePath}`;
|
||||
return relativeToRoot ? filePath : `${process.cwd()}/${filePath}`;
|
||||
}
|
||||
function getProjectVersion(filePath) {
|
||||
const projectInfoFile = require(filePath);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user