Skip to content

Commit

Permalink
Better file path handling for reporters. Fixes apiaryio#48
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Cordell committed Mar 10, 2014
1 parent 4b20e05 commit d643e0a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dredd",
"version": "0.3.0",
"version": "0.3.1",
"description": "API Blueprint testing tool",
"main": "lib/dredd.js",
"bin": {
Expand All @@ -27,7 +27,8 @@
"advisable": "~0.2.0",
"proxyquire": "~0.5.1",
"coffee-script": "1.6.3",
"glob": "~3.2.8"
"glob": "~3.2.8",
"file": "~0.2.2"
},
"devDependencies": {
"coffee-errors": "~0.8.4",
Expand Down
3 changes: 2 additions & 1 deletion src/reporters/html-reporter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
fs = require 'fs'

marked = require 'marked'
file = require 'file'

logger = require './../logger'
prettifyResponse = require './../prettify-response'
Expand Down Expand Up @@ -29,7 +30,7 @@ class HtmlReporter extends EventEmitter
@configureEmitter emitter

sanitizedPath: (path) =>
filePath = if path? then process.cwd() + "/" + path else process.cwd() + "/report.html"
filePath = if path? then file.path.abspath(path) else file.path.abspath("./report.html")
if fs.existsSync(filePath)
logger.info "File exists at #{filePath}, will be overwritten..."
filePath
Expand Down
4 changes: 3 additions & 1 deletion src/reporters/markdown-reporter.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{EventEmitter} = require 'events'
fs = require 'fs'

file = require 'file'

logger = require './../logger'
prettifyResponse = require './../prettify-response'

Expand All @@ -17,7 +19,7 @@ class MarkdownReporter extends EventEmitter
@configureEmitter emitter

sanitizedPath: (path) =>
filePath = if path? then process.cwd() + "/" + path else process.cwd() + "/report.md"
filePath = if path? then file.path.abspath(path) else file.path.abspath("./report.md")
if fs.existsSync(filePath)
logger.info "File exists at #{filePath}, will be overwritten..."
filePath
Expand Down
3 changes: 2 additions & 1 deletion src/reporters/x-unit-reporter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
fs = require 'fs'

htmlencode = require 'htmlencode'
file = require 'file'

logger = require './../logger'
prettifyResponse = require './../prettify-response'
Expand All @@ -17,7 +18,7 @@ class XUnitReporter extends EventEmitter
@configureEmitter emitter

sanitizedPath: (path) =>
filePath = if path? then process.cwd() + "/" + path else process.cwd() + "/report.xml"
filePath = if path? then file.path.abspath(path) else file.path.abspath("./report.xml")
if fs.existsSync(filePath)
logger.info "File exists at #{filePath}, will be overwritten..."
filePath
Expand Down

0 comments on commit d643e0a

Please sign in to comment.