我想知道是否有办法将这两个单独的任务合二为一. 
  
 
此concat-js任务要求在运行之前存在生成的文件.任务cache-angular-templates生成该文件.生成的文件需要包含在concat输出中.在完成concat-js之后,可以删除该文件 – 不再需要它.
似乎我应该以某种方式能够将cache-angular-tempaltes中使用的流管道输入到concat-js使用的流中.
gulp.task('concat-js',['cache-angular-templates'],function () {
    var concatOutputPath = path.dirname(paths.compiledScriptsFile),concatOutputFileName = path.basename(paths.compiledScriptsFile),jsFiles = [].concat(
            paths.libScripts,paths.appScripts,paths.templateScriptFile,notpath(paths.compiledScriptsFile),notpath(paths.specmockScripts),notpath(paths.specscripts)
        );
    return gulp
        .src(jsFiles)
        .pipe(buildTools.concat(concatOutputFileName))
        .pipe(gulp.dest(concatOutputPath))
        .on('end',function () {
            del(paths.templateScriptFile);
        })
    ;
});
gulp.task('cache-angular-templates',function () {
    var cacheOutputPath = path.dirname(paths.templateScriptFile),cacheOutputFileName = path.basename(paths.templateScriptFile);
    var options = {
        root: '/' + cacheOutputPath,standalone: true,filename: cacheOutputFileName
    };
    return gulp
        .src(paths.templates)
        .pipe(buildTools.angularTemplatecache(options))
        .pipe(gulp.dest(cacheOutputPath))
    ;
});
 确实你应该合并它们,因为Gulp的一个想法是消除中间临时文件. 
  
 
                    
                    
                实现它的方法之一是:
>将cache-angular-templates转换为返回模板流的函数,我们称之为getTemplateStream;
>从中删除.pipe(gulp.dest(cacheOutputPath));
>在将流连接到主任务之前使用event-stream合并流.你的主要任务将是这样的:
var es = require('event-stream');
gulp.task('concat-js',notpath(paths.specscripts)
        );
    return es.merge(gulp.src(jsFiles),getTemplateStream())
        .pipe(buildTools.concat(concatOutputFileName))
        .pipe(gulp.dest(concatOutputPath));
});
function getTemplateStream() {
    var options = {
        root: '/' + cacheOutputPath,filename: cacheOutputFileName
    };
    return gulp
        .src(paths.templates)
        .pipe(buildTools.angularTemplatecache(options));
} 
 通过执行此操作,您将合并两个流,并且getTemplateStream的输出文件将沿管道发送.