正确的信号流完成方式

时间:2017-10-03 18:08:35

标签: gulp

我创建了一个将数据传输到文件中并为每行数据输出单个文件的函数。但是,有35K行的数据要编译,尽管下面的代码表示"已完成"约5分钟后,文件仍在处理中。我无法启动下一个功能,直到完成这个功能,所以我需要知道它何时完成。

function createLocations(done) {
if (GENERATE_LOCATIONS) {

    for (var i = 0; i < locations.length; i++) {
        var location = locations[i],
           fileName = 'location-' + location.area.replace(/ +/g, '-').replace(/'+/g, '').replace(/&+/g, 'and').toLowerCase() + '-' + location.town.replace(/ +/g, '-').replace(/'+/g, '').replace(/`+/g, '').replace(/&+/g, 'and').toLowerCase();
        gulp.src('./templates/location-template.html')
            .pipe($.rename(fileName + ".html"))      
            .pipe(gulp.dest('./tmp/'));
        }
    }
    done();
    console.log('Creating '+locations.length+' Files Please Wait...');
}

该功能在发出信号后再运行15分钟。感谢任何帮助,以检测功能的实际完成。

非常感谢!

0 个答案:

没有答案
相关问题