Skip to content

Instantly share code, notes, and snippets.

@techieBrandon
Created October 21, 2015 20:40
Show Gist options
  • Save techieBrandon/f082e9a1c7dc20b83884 to your computer and use it in GitHub Desktop.
Save techieBrandon/f082e9a1c7dc20b83884 to your computer and use it in GitHub Desktop.
Grunt scripts:exist task
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