Skip to content

Commit 0199859

Browse files
committed
fix: Ensure parent directory, if JSON report has to be generated too
1 parent 5a1e092 commit 0199859

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules
33
npm-debug.log
44
tests/actual
5+
tests/extra

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = function (grunt) {
5454
includeUnreported: true
5555
},
5656
input: 'tests/actual/deprecated.*',
57-
src: 'tests/expected/missing.json',
57+
src: 'tests/extra/missing.json',
5858
dest: 'tests/actual/unreported.html'
5959
}
6060
},
@@ -64,7 +64,7 @@ module.exports = function (grunt) {
6464
},
6565

6666
clean: {
67-
tests: ['tests/actual/*']
67+
tests: ['tests/actual/*', 'tests/extra']
6868
}
6969
})
7070

tasks/grunt-html-html-report-converter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ module.exports = function (grunt) {
7777
})
7878
if (report.length) {
7979
const output = file.orig.src[0]
80+
const dir = path.dirname(output)
81+
grunt.file.mkdir(dir)
8082
fs.writeFileSync(output, JSON.stringify(report), 'utf-8')
8183
src = [output]
8284
}

tests/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ exports['htmllint-html-report-converter'] = {
2626
compare(test, 'report.html', 'report.htm')
2727
},
2828

29+
'unreported-json': function (test) {
30+
test.expect(2)
31+
const json = fs.statSync(path.join(__dirname, 'extra', 'missing.json'))
32+
test.ok(json)
33+
test.ok(json.size > 0)
34+
test.done()
35+
},
36+
2937
unreported: function (test) {
3038
compare(test, 'unreported.html', 'unreported.html')
3139
}

0 commit comments

Comments
 (0)