Skip to content

Commit

Permalink
Merge pull request #37 from GregoryGost/develop
Browse files Browse the repository at this point in the history
Version 1.0.3
  • Loading branch information
GregoryGost authored Apr 21, 2024
2 parents ed2fa95 + c69472a commit 05ab36a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('config.ts', () => {
//
process.env.GITHUB_SHA = 'c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c';
process.env.GITHUB_HEAD_REF = 'develop';
process.env.GITHUB_WORKSPACE = '';
//
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation();
getInputMock = jest.spyOn(core, 'getInput').mockImplementation();
Expand Down Expand Up @@ -57,6 +58,13 @@ describe('config.ts', () => {
expect(config.root).toBe(currentDir);
expect(infoMock).toHaveBeenNthCalledWith(1, `Root directory: ${currentDir}`);
});
it('get root path with GITHUB_WORKSPACE env', async () => {
const currentDir: string = normalize(cwd());
process.env.GITHUB_WORKSPACE = currentDir;
const config: Config = new Config();
expect(config.root).toBe(currentDir);
expect(infoMock).toHaveBeenNthCalledWith(1, `Root directory: ${currentDir}`);
});
/**
* Get input version test
*/
Expand Down
14 changes: 14 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gregory-gost/version-tagger",
"version": "1.0.2",
"version": "1.0.3",
"description": "GitHub Action to automate tag-based version control. For both production and development.",
"license": "GPL-3",
"private": true,
Expand Down
7 changes: 7 additions & 0 deletions src/class/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { env } from 'node:process';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { dirname, normalize, join } from 'node:path';
import { existsSync, readFileSync } from 'node:fs';
Expand Down Expand Up @@ -253,9 +254,15 @@ class Config {

/**
* Determining the Project Root Path
* * Github variables: <https://docs.github.com/en/actions/learn-github-actions/variables>
* @returns {string} application root path
*/
private static getRootDir(): string {
if (env.GITHUB_WORKSPACE !== undefined && env.GITHUB_WORKSPACE !== '') {
const finalCurrentDir = normalize(env.GITHUB_WORKSPACE);
info(`Root directory: ${finalCurrentDir}`);
return finalCurrentDir;
}
const filename: string = fileURLToPath(pathToFileURL(__filename).toString());
const dir = dirname(filename);
let currentDir: string = dir;
Expand Down

0 comments on commit 05ab36a

Please sign in to comment.