gulp - 我的代码在 gulp 任务结束后执行
问题描述
我构建了一个异步 gulp 任务来将一些 sass 文件转换为 css 文件,但我在执行时间线代码时遇到了一些麻烦。我需要在循环中执行这个任务,代码在 gulp 任务结束后执行
async build() {
var self = this;
var tasks = await this.themes.map(async(theme) => {
return gulp.src(this.templatesPath + '/' + this.pattern)
.pipe(header('@import \'' + this.themesPath + '/' + theme + '/' + this.themeFile + '\';'))
.pipe(sass.sync().on('error', gutil.log))
.pipe(rename(function (path: any) {
var file = path.basename + path.extname;
path.dirname += '/' + file;
gutil.log(self.folders[theme][file]);
}))
.pipe(gulp.dest(this.themesPath + '/' + theme))
gutil.log('loop');
});
gutil.log('end');
}
重命名函数中的gutil.log 输出总是在任务结束后输出
[18:08:34] 开始“构建”...
[18:08:34] 结束
[18:08:34] 33 毫秒后完成“构建”
[18:08:34] [ { '$': { 'jcr:primaryType': 'jnt:file' },
'jcr:content': [[Object] ] } ]
[18:08:34] [ { '$': { 'jcr:primaryType': 'jnt:file ' },
'jcr:content': [ [对象] ] } ]
当我执行其他任务时,如何处理循环结束以确保我的对象被填充?
解决方案
推荐阅读
- entity-framework-core - 具有空引用的 EF Core Select 查询
- mysql - 错误 1045 (28000):Amazon Linux 2 上 mysql Ver 15.1 的用户 'root'@'localhost' 的访问被拒绝(使用密码:YES)
- android - 将产品搜索后端添加到 ML Kit 展示中
- python - Discord.py,on_raw_reaction_add add_roles 不起作用
- jenkins - 如何一次从一个参数运行多个选择?
- android - 通过应用栏中的选择进行排序后,如何重新膨胀列表片段
- xamarin.forms - 在 Xamarin 表单中向下滚动时关闭 Rg.Plugins.Popup
- go - 使用所需模块的旧版本编译 go 源代码
- sql - SQL:组合两个表进行查询
- google-sheets - IMPORTXML 内容为空