对于问题 2,我看到了这个 gulp-jasmine 选项:
errorOnFail
Default: true
Stops the stream on failed tests.
.pipe(jasmine({errorOnFail: false}))
应该运行其余的测试。
问题 1:有多种方法可以指示 gulp.src 的多个来源,例如
return gulp.src([ './app/spec/*.js', 'spec/**/*.js'])
或设置一个变量:
var testSources = ['./app/spec/*.js', 'spec/**/*.js'];
return gulp.src(testSources)
或者我使用这样的东西:
var paths = {
html: {
src: "home.html",
temp: "./temp",
deploy: "./deploy/html"
},
sass: {
src: "./src/styles/scss/**/*.scss",
stylesFile: "./src/styles/scss/styles.scss"
},
css: {
src: "./temp/css/styles.css",
temp: "./temp/css",
deploy: "./deploy/css"
},
js: {
src: "./src/js/**/*.js",
temp: "./temp/js",
deploy: "./deploy/js"
}
};
然后使用:
function reloadJS() {
return gulp.src(paths.js.src)
.pipe(sourcemaps.init())
.pipe(sourcemaps.write("../sourcemaps", {includeContent:false,sourceRoot:"/js"}))
.pipe(gulp.dest(paths.js.temp))
.pipe(reload({ stream:true }));
}
顺便说一句,将两个问题放在一篇文章中通常是不赞成的。