在gulp job中运行异步操作

时间:2015-11-18 11:25:18

标签: javascript gulp

我使用gulp-processhtml根据html评论更新我的html。我需要使用选项将相同的变量传递给它的引擎:

gulp.task('buildIndex', ['clean', 'copyStatic'], function () {
    return gulp.src('src/static/index.html').pipe(processhtml({
        data: { name: 'myname' }
    })).pipe(gulp.dest('dist/static'));
});

一切正常。

现在我需要检索' myname'使用异步任务的值,例如从文件系统读取它。如何在我的gulp流管道中混合这个新任务?

由于

1 个答案:

答案 0 :(得分:-1)

我用这种方式解决了使用Q并返回一个承诺:

web.1  | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Warrens-iMac.local. Set the 'ServerName' directive globally to suppress this message
web.1  | DOCUMENT_ROOT changed to 'web/'
web.1  | 4 processes at 128MB memory limit.
web.1  | Starting php-fpm...
web.1  | Starting httpd...
web.1  | Application ready for connections on port 5000.
web.1  | httpd: Syntax error in -C/-c directive: Include takes one argument, Name(s) of the config file(s) to be included; fails if the wildcard does not match at least one file
web.1  | Process exited unexpectedly: httpd
web.1  | Going down, terminating child processes...
web.1  | [Wed Dec  2 10:55:49 2015]  Script:  '-'

不知道这是否是最优雅的方式,但效果非常好。