Skip to content

Commit 419e1a9

Browse files
committed
Apply standard style to all files
1 parent d7ae243 commit 419e1a9

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

lib/pdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function PDF (html, options) {
3737
this.options.phantomArgs = this.options.phantomArgs || []
3838
assert(this.options.phantomPath, "html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'")
3939
assert(typeof this.html === 'string' && this.html.length, "html-pdf: Can't create a pdf without an html string")
40-
this.options.timeout = parseInt(this.options.timeout) || 30000
40+
this.options.timeout = parseInt(this.options.timeout, 10) || 30000
4141
}
4242

4343
PDF.prototype.toBuffer = function PdfToBuffer (callback) {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"html-pdf": "bin/index.js"
1414
},
1515
"scripts": {
16-
"standard": "standard bin/index.js",
17-
"test": "npm run standard && node test/index.js"
16+
"test": "standard && node test/index.js"
1817
},
1918
"author": "Marc Bachmann",
2019
"license": "MIT",

test/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test('pdf.create(html[, options]).toFile([filename, ]callback)', function (t) {
4141

4242
pdf.create(html).toFile(function (err, pdf) {
4343
t.error(err)
44-
t.assert(typeof pdf.filename == 'string', `toFile(callback) returns {filename: '${pdf.filename}'} as second cb argument`)
44+
t.assert(typeof pdf.filename === 'string', `toFile(callback) returns {filename: '${pdf.filename}'} as second cb argument`)
4545
fs.unlink(pdf.filename)
4646
})
4747

@@ -58,8 +58,8 @@ test('pdf.create(html).toBuffer(callback)', function (t) {
5858

5959
pdf.create(html).toBuffer(function (err, pdf) {
6060
t.error(err)
61-
t.assert(Buffer.isBuffer(pdf), "toBuffer(callback) returns a buffer instance as second cb argument")
62-
t.assert(/^\%PDF-1.4/.test(pdf.slice(0, 100).toString()), "the PDF buffer has a PDF Header")
61+
t.assert(Buffer.isBuffer(pdf), 'toBuffer(callback) returns a buffer instance as second cb argument')
62+
t.assert(/^\%PDF-1.4/.test(pdf.slice(0, 100).toString()), 'the PDF buffer has a PDF Header')
6363
})
6464
})
6565

@@ -68,17 +68,17 @@ test('pdf.create(html, {directory: "/tmp"}).toBuffer(callback)', function (t) {
6868

6969
pdf.create(html, {directory: '/tmp'}).toBuffer(function (err, pdf) {
7070
t.error(err)
71-
t.assert(Buffer.isBuffer(pdf), "uses the passed directory as tmp dir")
71+
t.assert(Buffer.isBuffer(pdf), 'uses the passed directory as tmp dir')
7272
})
7373
})
7474

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

78-
stream = pdf.create(html).toStream(function (err, stream) {
78+
pdf.create(html).toStream(function (err, stream) {
7979
t.error(err)
80-
t.assert(stream instanceof fs.ReadStream, "toStream(callback) returns a fs.ReadStream as second cb argument")
81-
destination = path.join(__dirname, 'streamed.pdf')
80+
t.assert(stream instanceof fs.ReadStream, 'toStream(callback) returns a fs.ReadStream as second cb argument')
81+
var destination = path.join(__dirname, 'streamed.pdf')
8282
stream.pipe(fs.createWriteStream(destination))
8383
stream.on('end', function () {
8484
t.assert(fs.existsSync(destination), 'toStream returns a working readable stream')
@@ -95,7 +95,7 @@ test('allows custom html and css', function (t) {
9595

9696
var template = path.join(__dirname, '../example/businesscard.html')
9797
var filename = template.replace('.html', '.pdf')
98-
var templateHtml = fs.readFileSync(template, 'utf8')
98+
var templateHtml = fs.readFileSync(template, 'utf8')
9999

100100
var image = path.join('file://', __dirname, '../example/image.png')
101101
templateHtml = templateHtml.replace('{{image}}', image)
@@ -148,7 +148,7 @@ test('allows custom page and footer options', function (t) {
148148
.create(html, options)
149149
.toFile(filename, function (error, pdf) {
150150
t.error(error)
151-
t.assert(pdf.filename == filename, 'Returns the filename from the phantom script')
151+
t.assert(pdf.filename === filename, 'Returns the filename from the phantom script')
152152
t.assert(fs.existsSync(pdf.filename), 'Saves the pdf with a custom page size and footer')
153153
})
154154
})
@@ -162,7 +162,7 @@ test('allows different header and footer for first page', function (t) {
162162
.create(enrichedHtml, {quality: 100})
163163
.toFile(filename, function (error, pdf) {
164164
t.error(error)
165-
t.assert(pdf.filename == filename, 'Returns the filename from the phantom script')
165+
t.assert(pdf.filename === filename, 'Returns the filename from the phantom script')
166166
t.assert(fs.existsSync(pdf.filename), 'Saves the pdf with a custom page size and footer')
167167
})
168168
})
@@ -176,7 +176,7 @@ test('load external css', function (t) {
176176
.create(enrichedHtml)
177177
.toFile(filename, function (error, pdf) {
178178
t.error(error)
179-
t.assert(pdf.filename == filename, 'Returns the filename from the phantom script')
179+
t.assert(pdf.filename === filename, 'Returns the filename from the phantom script')
180180
t.assert(fs.existsSync(pdf.filename), 'Saves the pdf with a custom page size and footer')
181181
})
182182
})
@@ -190,7 +190,7 @@ test('load external js', function (t) {
190190
.create(enrichedHtml, {phantomArgs: ['--ignore-ssl-errors=true']})
191191
.toFile(filename, function (error, pdf) {
192192
t.error(error)
193-
t.assert(pdf.filename == filename, 'Returns the filename from the phantom script')
193+
t.assert(pdf.filename === filename, 'Returns the filename from the phantom script')
194194
t.assert(fs.existsSync(pdf.filename), 'Saves the pdf with a custom page size and footer')
195195
})
196196
})

0 commit comments

Comments
 (0)