File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ PDF.prototype.exec = function PdfExec (callback) {
105
105
return child . kill ( )
106
106
} )
107
107
108
+ child . on ( 'error' , function ( error ) {
109
+ clearTimeout ( timeout )
110
+ return callback ( error )
111
+ } )
112
+
108
113
child . on ( 'exit' , function ( code ) {
109
114
clearTimeout ( timeout )
110
115
if ( code || stderr . length ) {
Original file line number Diff line number Diff line change @@ -114,6 +114,24 @@ test('allows custom html and css', function (t) {
114
114
} )
115
115
} )
116
116
117
+ test ( 'allows invalid phantomPath' , function ( t ) {
118
+ t . plan ( 3 )
119
+
120
+ var filename = path . join ( __dirname , 'invalid-phantomPath.pdf' )
121
+
122
+ var options = {
123
+ phantomPath : '/bad/path/to/phantom'
124
+ }
125
+
126
+ pdf
127
+ . create ( html , options )
128
+ . toFile ( filename , function ( error , pdf ) {
129
+ t . assert ( error instanceof Error , 'Returns an error' )
130
+ t . equal ( error . code , 'ENOENT' , 'Error code is ENOENT' )
131
+ t . error ( pdf , 'PDF does not exist' )
132
+ } )
133
+ } )
134
+
117
135
test ( 'allows custom page and footer options' , function ( t ) {
118
136
t . plan ( 3 )
119
137
You can’t perform that action at this time.
0 commit comments