You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module.exports.register=function(Driver,config){varpath=require('path');varfs=require('fs');functionreadKey(obj,i){returnobj&&iinobj ? obj[i] : null;}vardestDir='screenstory.storage'.split('.').reduce(readKey,config);destDir||(destDir=path.resolve(process.cwd(),"screenshots"));createFullPath(destDir,function(err){if(err)console.log(err);elseconsole.log('"%s" created to store screenshots',destDir);});Driver.prototype.thenScreenstory=function(id){returnthis.thenTakeScreenshot(function(image,next){saveScreenshot(id,image,this._desired,next);});};functionsaveScreenshot(id,b64screen,desired,next){varfile=filename(id,desired);fs.writeFile(file,b64screen,'base64',function(err){next(err);});}functionfilename(id,desired){returnpath.resolve(destDir,id+'_'+desired.browserName+'.png');}// thx to https://gist.github.com/aelaguiz/864454functioncreateFullPath(fullPath,callback){varparts=path.normalize(fullPath).split("/"),working='/',pathList=[];for(vari=0,max=parts.length;i<max;i++){working=path.join(working,parts[i]);pathList.push(working);}varrecursePathList=functionrecursePathList(paths){if(0===paths.length){callback(null);return;}varworking=paths.shift();try{fs.exists(working,function(exists){if(!exists){try{fs.mkdir(working,0755,function(){recursePathList(paths);});}catch(e){callback(newError("Failed to create path: "+working+" with "+e.toString()));}}else{recursePathList(paths);}});}catch(e){callback(newError("Invalid path specified: "+working));}};if(0===pathList.length)callback(newError("Path list was empty"));elserecursePathList(pathList);}};
The text was updated successfully, but these errors were encountered:
For easy saving
The text was updated successfully, but these errors were encountered: