Skip to content

Commit 07efbf9

Browse files
authored
Merge pull request #26 from dhershman1/feature/#23-specify-ext-name
Feature/#24 specify ext name
2 parents 0b25c2a + 54045d2 commit 07efbf9

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ IF you are editing exsiting functionality please ensure all unit tests remain pa
1717
## Developing
1818

1919
- Please stick to the [standardjs](https://standardjs.com/) style for development
20+
- This lib is written using ES6 please keep all changes to this version
21+
- This excludes the import/export since node does not support it internally yet
2022
- Make sure all current and new units tests are fully passing
2123
- Please try to keep the flow consistent to what is already present
2224

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# VERSION NUMBER
2-
31
Please give a light description of your changes here
42

53
## Breaking Changes

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ tape tests/thing.js | tap-junit > output/thing.xml
4343
tap-junit -i tap.txt -s suite-name
4444
```
4545

46+
You can now use custom extensions (in version 3.1.0+) simply add the extension to the end of your file name. If none is provided `tap-junit` will still default to `.xml`
47+
48+
`tape test/*.js | tap-junit -o output/tests -n tape.xuni`
49+
50+
The above will create a file called `tape.xuni` in the `output/tests` directory with the results inside.
51+
4652
## Output
4753

4854
```xml

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tap-junit",
3-
"version": "3.0.2",
3+
"version": "3.1.0",
44
"description": "Silly small, silly easy junit output formatter for tap.",
55
"main": "src/index.js",
66
"bin": {
@@ -10,7 +10,7 @@
1010
"prepack": "npm run lint",
1111
"clear": "rimraf output/**",
1212
"test": "tape tests/pass.js | cross-env bin/tap-junit -o output/test -n pass -s suite-name",
13-
"test:input": "cross-env bin/tap-junit --output output --name api --suite api-test --input tests/non-tape.tap",
13+
"test:input": "cross-env bin/tap-junit --output output --name api.xuni --suite api-test --input tests/non-tape.tap",
1414
"test:zero": "tape tests/pass.js | cross-env bin/tap-junit > output/pass-zero.xml",
1515
"test:nontape": "cross-env bin/tap-junit --output output/test --name nontape.xml < tests/non-tape.tap",
1616
"test:nooutput": "tape tests/pass.js | cross-env bin/tap-junit",

src/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
/* Modules */
22
const { EOL } = require('os')
3+
const path = require('path')
34
const parser = require('tap-out')
45

56
const serialize = require('./serialize')
67
const write = require('./write')
78

89
const tapJunit = args => {
910
let testCase = null
11+
// Keep track of custom extensions
12+
let extension = '.xml'
1013
const testSuites = []
1114
const tap = parser()
1215

1316
/* Helpers */
1417
const sanitizeString = (str = 'tap') => {
18+
const { name, ext } = path.parse(str)
1519
// In case the user included .xml in the name argument lets get rid of it
16-
if (str.includes('.xml')) {
17-
return str.replace('.xml', '').replace(/[^\w-_]/g, '').trim()
20+
21+
if (ext) {
22+
extension = ext
1823
}
1924

20-
return str.replace(/[^\w-_]/g, '').trim()
25+
return name.replace(/[^\w-_]/g, '').trim()
2126
}
2227

2328
/**
@@ -27,7 +32,7 @@ const tapJunit = args => {
2732
*/
2833
const writeOutput = (xml, passing) => {
2934
const name = sanitizeString(args.name)
30-
const fileName = `${name}.xml`
35+
const fileName = `${name}${extension}`
3136

3237
write(args.output, fileName, xml)
3338
.then(() => {

0 commit comments

Comments
 (0)