Skip to content

Commit 325ae3c

Browse files
committed
#23 Added workingdir option
1 parent f1927db commit 325ae3c

File tree

5 files changed

+46
-11
lines changed

5 files changed

+46
-11
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: 'Optional directory for storing persistent coverage information. Can be used in future reports to show coverage evolution.'
2323
required: false
2424
default: ''
25+
workingdir:
26+
description: 'Optional working directory. If available, the targetdir and historydir are interpreted relative to the working directory (only if not specified as absolute paths).'
27+
required: false
28+
default: ''
2529
toolpath:
2630
description: 'Default directory for installing the dotnet tool.'
2731
required: false

dist/index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
5252
const core = __importStar(__nccwpck_require__(7484));
5353
const exec = __importStar(__nccwpck_require__(5236));
5454
const fs = __importStar(__nccwpck_require__(9896));
55+
const path = __importStar(__nccwpck_require__(6928));
5556
const VERSION = '5.4.4';
5657
function run() {
5758
return __awaiter(this, void 0, void 0, function* () {
@@ -106,12 +107,25 @@ function run() {
106107
output = '';
107108
resultCode = 0;
108109
try {
109-
let args = [
110+
const workingdir = (core.getInput('workingdir') || '').trim();
111+
let targetdir = (core.getInput('targetdir') || '');
112+
let historydir = (core.getInput('historydir') || '');
113+
if (workingdir.length > 0) {
114+
if (targetdir.length > 0 && !path.isAbsolute(targetdir)) {
115+
targetdir = path.join(workingdir, targetdir);
116+
return;
117+
}
118+
if (historydir.length > 0 && !path.isAbsolute(historydir)) {
119+
historydir = path.join(workingdir, historydir);
120+
return;
121+
}
122+
}
123+
const args = [
110124
'-reports:' + (core.getInput('reports') || ''),
111-
'-targetdir:' + (core.getInput('targetdir') || ''),
125+
'-targetdir:' + targetdir,
112126
'-reporttypes:' + (core.getInput('reporttypes') || ''),
113127
'-sourcedirs:' + (core.getInput('sourcedirs') || ''),
114-
'-historydir:' + (core.getInput('historydir') || ''),
128+
'-historydir:' + historydir,
115129
'-plugins:' + (core.getInput('plugins') || ''),
116130
'-assemblyfilters:' + (core.getInput('assemblyfilters') || ''),
117131
'-classfilters:' + (core.getInput('classfilters') || ''),

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
"devDependencies": {
2323
"@types/node": "^22.13.0",
2424
"@vercel/ncc": "^0.38.3",
25-
"typescript": "^5.7.3"
25+
"typescript": "^5.8.2"
2626
}
2727
}

src/reportgenerator.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from '@actions/core';
22
import * as exec from '@actions/exec';
33
import * as fs from 'fs';
4+
import * as path from 'path';
45

56
const VERSION = '5.4.4';
67

@@ -72,12 +73,28 @@ async function run() {
7273
resultCode = 0;
7374

7475
try {
75-
let args = [
76+
const workingdir = (core.getInput('workingdir') || '').trim();
77+
78+
let targetdir = (core.getInput('targetdir') || '');
79+
let historydir = (core.getInput('historydir') || '');
80+
81+
if (workingdir.length > 0) {
82+
if (targetdir.length > 0 && !path.isAbsolute(targetdir)) {
83+
targetdir = path.join(workingdir, targetdir);
84+
return;
85+
}
86+
if (historydir.length > 0 &&!path.isAbsolute(historydir)) {
87+
historydir = path.join(workingdir, historydir);
88+
return;
89+
}
90+
}
91+
92+
const args = [
7693
'-reports:' + (core.getInput('reports') || ''),
77-
'-targetdir:' + (core.getInput('targetdir') || ''),
94+
'-targetdir:' + targetdir,
7895
'-reporttypes:' + (core.getInput('reporttypes') || ''),
7996
'-sourcedirs:' + (core.getInput('sourcedirs') || ''),
80-
'-historydir:' + (core.getInput('historydir') || ''),
97+
'-historydir:' + historydir,
8198
'-plugins:' + (core.getInput('plugins') || ''),
8299
'-assemblyfilters:' + (core.getInput('assemblyfilters') || ''),
83100
'-classfilters:' + (core.getInput('classfilters') || ''),

0 commit comments

Comments
 (0)