Skip to content

Commit

Permalink
add configuration for custom pkg names (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszx0 authored Feb 8, 2021
1 parent 0c778db commit 48645c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
uses: guyarb/[email protected]
with:
test-results: test.json
package-name: foobar # optional, if using custom package name, github.com/owner/repo stripped from the pathname by default
```
## Development of this action
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const lineReader = require('line-by-line');

try {
const testResultsPath = core.getInput('test-results');
const customPackageName = core.getInput('package-name');

var obj = new Object();
var lr = new lineReader(testResultsPath);
Expand All @@ -18,8 +19,12 @@ try {
return;
}
output = output.replace("\n", "%0A").replace("\r", "%0D")
// Removing the github.com/owner/reponame
// Strip github.com/owner/repo package from the path by default
var packageName = currentLine.Package.split("/").slice(3).join("/");
// If custom package is provided, strip custom package name from the path
if (customPackageName != null) {
packageName = currentLine.Package.replace(customPackageName + "/", "")
}
var newEntry = packageName + "/" + testName;
if (!obj.hasOwnProperty(newEntry)) {
obj[newEntry] = output;
Expand Down

0 comments on commit 48645c3

Please sign in to comment.