File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,11 @@ PDF.prototype.exec = function PdfExec (callback) {
105105 return child . kill ( )
106106 } )
107107
108+ child . on ( 'error' , function ( error ) {
109+ clearTimeout ( timeout )
110+ return callback ( error )
111+ } )
112+
108113 child . on ( 'exit' , function ( code ) {
109114 clearTimeout ( timeout )
110115 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) {
114114 } )
115115} )
116116
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+
117135test ( 'allows custom page and footer options' , function ( t ) {
118136 t . plan ( 3 )
119137
You can’t perform that action at this time.
0 commit comments