Skip to content

Commit

Permalink
Merge pull request #117 from marcbachmann/fix-tmp-dir-path
Browse files Browse the repository at this point in the history
Fix tmp directory path
  • Loading branch information
marcbachmann committed Feb 19, 2016
2 parents 891b9e5 + f88cd01 commit 46008df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/scripts/pdf_a4_portrait.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ page.onLoadFinished = function (status) {
quality: options.quality || 75
}

var filename = options.filename || (options.directory || '/tmp' + '/html-pdf-' + system.pid + '.' + fileOptions.type)
var filename = options.filename || (options.directory || '/tmp') + '/html-pdf-' + system.pid + '.' + fileOptions.type
page.render(filename, fileOptions)
system.stdout.write(JSON.stringify({filename: filename}))

Expand Down
11 changes: 10 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test('pdf.create(html[, options]).toFile([filename, ]callback)', function (t) {
})
})

test('pdf.create(html[, options]).toBuffer(callback)', function (t) {
test('pdf.create(html).toBuffer(callback)', function (t) {
t.plan(3)

pdf.create(html).toBuffer(function (err, pdf) {
Expand All @@ -63,6 +63,15 @@ test('pdf.create(html[, options]).toBuffer(callback)', function (t) {
})
})

test('pdf.create(html, {directory: "/tmp"}).toBuffer(callback)', function (t) {
t.plan(2)

pdf.create(html, {directory: '/tmp'}).toBuffer(function (err, pdf) {
t.error(err)
t.assert(Buffer.isBuffer(pdf), "uses the passed directory as tmp dir")
})
})

test('pdf.create(html[, options]).toStream(callback)', function (t) {
t.plan(3)

Expand Down

0 comments on commit 46008df

Please sign in to comment.