mirror of
https://github.com/ditkrg/project-version-check.git
synced 2026-01-22 22:06:42 +00:00
fix file path error
Signed-off-by: Shakar <5h4k4r.b4kr@gmail.com>
This commit is contained in:
parent
337fc055f9
commit
fd3c042b3e
14
index.js
14
index.js
@ -11,7 +11,8 @@ async function run() {
|
||||
const filePathInput = core.getInput('filePath');
|
||||
const labelInput = core.getInput('label');
|
||||
|
||||
const file = getProjectInfoFile(filePathInput);
|
||||
const filePath = getProjectInfoFilePath(filePathInput);
|
||||
const file = require(filePath);
|
||||
|
||||
|
||||
console.log(`Label: ${labelInput}`)
|
||||
@ -19,7 +20,7 @@ async function run() {
|
||||
|
||||
core.setOutput("label", labelInput);
|
||||
|
||||
const version = getProjectVersion(file);
|
||||
const version = getProjectVersion(filePath);
|
||||
|
||||
// the version is in semantic format, so we can split it by dot
|
||||
const versionParts = version.split('.');
|
||||
@ -43,7 +44,7 @@ async function run() {
|
||||
// join the parts back together
|
||||
const newVersion = versionParts.join('.');
|
||||
|
||||
updateProjectVersion(file, newVersion);
|
||||
updateProjectVersion(filePath, newVersion);
|
||||
|
||||
console.log(`Old version: ${version}. New version: ${newVersion}`)
|
||||
|
||||
@ -159,18 +160,17 @@ async function commitChanges(filePath, file) {
|
||||
}
|
||||
}
|
||||
|
||||
function getProjectInfoFile(filePath) {
|
||||
function getProjectInfoFilePath(filePath) {
|
||||
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 require(`${process.cwd()}/${projectInfoFile}`);
|
||||
return `${process.cwd()}/${projectInfoFile}`;
|
||||
}
|
||||
else
|
||||
return require(`${process.cwd()}/${filePath}`);
|
||||
return `${process.cwd()}/${filePath}`;
|
||||
}
|
||||
|
||||
function getProjectVersion(filePath) {
|
||||
const projectInfoFile = require(filePath);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user