Skip to content

Instantly share code, notes, and snippets.

@techieBrandon
Created October 21, 2015 20:40
Show Gist options
  • Select an option

  • Save techieBrandon/f082e9a1c7dc20b83884 to your computer and use it in GitHub Desktop.

Select an option

Save techieBrandon/f082e9a1c7dc20b83884 to your computer and use it in GitHub Desktop.

Revisions

  1. techieBrandon created this gist Oct 21, 2015.
    41 changes: 41 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    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)



    })