@@ -33,6 +33,8 @@ function processBlock(blk) {
3333
3434 var assetPath = ASSET_PATH ;
3535 var filePath = assetPath + crypto . createHash ( 'sha1' ) . update ( code ) . digest ( 'hex' ) + '.' + format ;
36+ var rootPath = book . output . root ( ) ;
37+ var destFilePath = path . join ( rootPath , assetPath ) ;
3638
3739 if ( this . ctx && this . ctx . ctx && this . ctx . ctx . file && this . ctx . ctx . file . path ) {
3840 var includePath = path . resolve ( path . dirname ( this . ctx . ctx . file . path ) ) ;
@@ -48,7 +50,7 @@ function processBlock(blk) {
4850 }
4951 }
5052
51- if ( fs . existsSync ( filePath ) ) {
53+ if ( fs . existsSync ( filePath ) && fs . existsSync ( destFilePath ) ) {
5254 var result = "<img src=/" + filePath + ">" ;
5355 deferred . resolve ( result ) ;
5456 } else {
@@ -64,17 +66,14 @@ function processBlock(blk) {
6466
6567 fs . writeFileSync ( filePath , buffer , function ( err ) {
6668 if ( err )
67- console . error ( err ) ;
69+ console . error ( err ) ;
6870 } ) ;
6971
7072 var result = "<img src=/" + filePath + ">" ;
7173
7274 // NOTE: fix https://github.com/vowstar/gitbook-plugin-uml/issues/17
7375 // To make sure the asserts always copied before pdf generation
7476 // Copy images to output folder every time
75- var output = book . output ;
76- var rootPath = output . root ( ) ;
77- var destFilePath = path . join ( rootPath , assetPath ) ;
7877 if ( fs . existsSync ( assetPath ) ) {
7978 // NOTE: fix https://github.com/vowstar/gitbook-plugin-uml/issues/22
8079 // When destFilePath exist, file should copied
0 commit comments