我正在尝试收集在1中调试所需的3个任务.当然,由于gulp的特性是异步的,因此我遇到了问题.因此,我搜索并找到了一种解决方案,以使用运行顺序模块来解决该问题.我尝试了以下代码,但似乎无法正常工作.它没有同步.
这是我尝试过的.有什么想法吗?我不想运行所有这三个命令来完成所有任务.我怎样才能做到这一点?
var gulp = require('gulp'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
debug = require('gulp-debug'),
rename = require("gulp-rename"),
replace = require('gulp-replace'),
runSequence = require('run-sequence'),
path = '../dotNet/VolleyManagement.UI';
gulp.task('debug', function () {
gulp.src('client/*.html')
.pipe(debug())
.pipe(gulp.dest(path + '/Areas/WebAPI/Views/Shared'));
});
gulp.task('rename', function () {
gulp.src(path + '/Areas/WebAPI/Views/Shared/index.html')
.pipe(rename('/Areas/WebAPI/Views/Shared/_Layout.cshtml'))
.pipe(gulp.dest(path));
gulp.src(path + '/Areas/WebAPI/Views/Shared/index.html', {read: false})
.pipe(clean({force: true}));
});
gulp.task('final', function(){
gulp.src([path + '/Areas/WebAPI/Views/Shared/_Layout.cshtml'])
.pipe(replace('href="', 'href="~/Content'))
.pipe(replace('src="', 'src="~/Scripts'))
.pipe(gulp.dest(path + '/Areas/WebAPI/Views/Shared/'));
});
gulp.task('debugAll', runSequence('debug', 'rename', 'final'));
解决方法:
我认为您没有正确定义“ debugAll”任务.尝试这样:
gulp.task('debugAll', function () {
runSequence('debug', 'rename', 'final');
});
而且,您还需要返回这些任务的流,只需在gulp.src前面为每个任务添加“ return”:调试,重命名,最终操作.这是“调试”任务的示例:
gulp.task('debug', function () {
return gulp.src('client/*.html')
.pipe(debug())
.pipe(gulp.dest(path + '/Areas/WebAPI/Views/Shared'));
});
在文档中都提到了这两项:https://www.npmjs.com/package/run-sequence