File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,10 @@ var Promise = require('bluebird'),
88 Logger = require ( './log.js' ) ,
99 defaults = require ( './defaults.js' ) ;
1010
11- var encoding = 'binary' ;
12-
1311/** @constructor */
1412var Loader = function ( data ) {
1513 var options = _ . clone ( data ) ,
14+ encoding = 'binary' ,
1615 loadedFiles = { } ,
1716 staticFullPaths ,
1817 logger ;
@@ -315,6 +314,10 @@ var Loader = function (data) {
315314 return p ;
316315 }
317316
317+ function errorCleanup ( ) {
318+ return fs . removeAsync ( options . path ) ;
319+ }
320+
318321 return {
319322 scrape : function ( callback ) {
320323 if ( fs . existsSync ( options . path ) ) {
@@ -326,7 +329,10 @@ var Loader = function (data) {
326329 return callback ( null , res )
327330 } )
328331 . catch ( function ( e ) {
329- return callback ( e , null )
332+ return errorCleanup ( )
333+ . then ( function ( ) {
334+ return callback ( e , null )
335+ } ) ;
330336 } )
331337 }
332338 }
You can’t perform that action at this time.
0 commit comments