Created
October 21, 2015 20:40
-
-
Save techieBrandon/f082e9a1c7dc20b83884 to your computer and use it in GitHub Desktop.
Grunt scripts:exist task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask('scripts:exist',function(){ | |
var filesList = grunt.template.process('<%= build.dist.js.dest %>').split(','); | |
// console.log(filesList); | |
var done = this.async(); | |
var interval; | |
var validate = function(){ | |
var missedFiles = []; | |
var validatedFile = []; | |
filesList.forEach(function(file){ | |
var exists = grunt.file.exists(file); | |
// console.log(file+" exist: "+exists); | |
if(!exists){ | |
missedFiles.push(file); | |
}else{ | |
validatedFile.push(file); | |
} | |
}); | |
validatedFile.forEach(function(file){ | |
grunt.verbose.ok(file+' generation validated.'); | |
}); | |
missedFiles.forEach(function(file){ | |
grunt.log.error(file+' not generated!'); | |
}); | |
if(missedFiles.length<1){ | |
clearInterval(interval); | |
done(); | |
} | |
}; | |
setInterval(validate,50) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment