我的gulp手表在发现这样的错误后崩溃了:
Error: File not found with singular glob: C:\Windows\......\controller.js
我认为通过使用Gulp Plumber可以解决这个问题。但它不起作用。我无法抓住这个错误。似乎有些东西我不知道。
这是我的script.js任务:
'use strict';
module.exports = (gulp, $) => () => {
let allLibsJsApp = $.env.paths.app.js.map((path) => { return `build/${path}` });
return $.merge2(
gulp.src($.env.paths.libs.js, {base: '.'}) // $.env.paths.libs.js is the problem about the file missing
.pipe($.plumber())
.pipe($.ngAnnotate())
.pipe($.if($.env.isProd, $.stripDebug()))
.pipe($.if($.env.isProd, $.size({title: 'Annotate and StripDebug NodeModules Libs JS'})))
.pipe($.if($.env.isDev, $.size({title: 'Annotate NodeModules Libs JS'})))
.pipe($.if($.env.isDev, gulp.dest('build/libs'))),
gulp.src(allLibsJsApp, {base: '.'})
.pipe($.plumber())
.pipe($.ngAnnotate())
.pipe($.babel())
.pipe($.if($.env.isProd,$.complexity({
breakOnErrors: false,
errorsOnly: false,
cyclomatic: [5],
halstead: [15],
maintainability: 100,
hideComplexFunctions: true,
})))
.pipe($.plumber())
.pipe($.if($.env.isProd, $.stripDebug()))
.pipe($.if($.env.isProd, $.size({title: 'Annotate, Babel and StripDebug App Libs JS'})))
.pipe($.if($.env.idDev, $.size({title: 'Annotate, Babel App Libs JS'})))
.pipe($.if($.env.isProd, $.replace('\'ngMockE2E\',','')))
.pipe($.if($.env.isProd, $.replace('$compileProvider.debugInfoEnabled(true)','$compileProvider.debugInfoEnabled(false)')))
.pipe($.if($.env.isProd, $.size({title: 'Uglify App libs JS'})))
.pipe($.if($.env.isDev, gulp.dest('.')))
)
.pipe($.plumber())
.pipe($.if($.env.isProd, $.concat('prod.js')))
.pipe($.if($.env.isProd, $.uglify({mangle: {except: ['notify', 'complete', '_transferable_']}})))
.pipe($.if($.env.isProd, $.size({title: 'Uglify All Libs JS'})))
.pipe($.if($.env.isProd, $.rev()))
.pipe($.if($.env.isProd, gulp.dest('build/libs')));
}
这是帮助您理解的过程视图。
> gulp build&&gulp serve
[13:08:46] Using gulpfile ~\Desktop\print-cards-web\Gulpfile.js
[13:08:46] Starting 'build'...
[13:08:46] Starting 'clean'...
[13:08:46] Finished 'clean' after 30 ms
[13:08:46] Starting 'assets-html'...
[13:08:46] Starting 'assets-js'...
[13:08:46] Starting 'assets-json'...
[13:08:46] Starting 'assets-img'...
[13:08:49] copy json assets all files 1.37 kB
[13:08:49] Finished 'assets-json' after 2.95 s
[13:08:49] Plumber found unhandled error:
SyntaxError in plugin 'gulp-babel'
Message:
C:/Users/TEST/Desktop/print-cards-web/src/app/controllers/generalController.js: Unexpected token (207:2)
[13:08:49] copy html assets all files 2.72 MB
[13:08:49] Finished 'assets-html' after 3.09 s
[13:08:49] copy img assets all files 587.98 kB
[13:08:49] Finished 'assets-img' after 3.12 s
[13:08:49] copy js assets all files 342.92 kB
[13:08:49] Finished 'assets-js' after 3.17 s
[13:08:49] Starting 'sass'...
[13:08:49] Starting 'scripts'...
[13:08:50] 'scripts' errored after 902 ms
[13:08:50] Error: File not found with singular glob: C:\Users\TEST\Desktop\print-cards-web\build\js\controllers\generalCon
at Glob.<anonymous> (C:\Users\TEST\Desktop\print-cards-web\node_modules\glob-stream\index.js:39:11)
at Glob.g (events.js:273:16)
at emitOne (events.js:90:13)
at Glob.emit (events.js:182:7)
at Glob._finish (C:\Users\TEST\Desktop\print-cards-web\node_modules\glob\glob.js:172:8)
at done (C:\Users\TEST\Desktop\print-cards-web\node_modules\glob\glob.js:159:12)
at Glob._processSimple2 (C:\Users\TEST\Desktop\print-cards-web\node_modules\glob\glob.js:652:12)
at C:\Users\TEST\Desktop\print-cards-web\node_modules\glob\glob.js:640:10
at Glob._stat2 (C:\Users\TEST\Desktop\print-cards-web\node_modules\glob\glob.js:736:12)
at lstatcb_ (C:\Users\TEST\Desktop\print-cards-web\node_modules\glob\glob.js:728:12)
at RES (C:\Users\TEST\Desktop\print-cards-web\node_modules\inflight\inflight.js:23:14)
at f (C:\Users\TEST\Desktop\print-cards-web\node_modules\once\once.js:17:25)
at FSReqWrap.oncomplete (fs.js:82:15)
[13:08:50] 'build' errored after 4.11 s
[13:08:50] The following tasks did not complete: sass
[13:08:50] Did you forget to signal async completion?
如您所见,我创建了一个语法错误来测试generalController.js中的管道工。管道工确实拦截了这个错误,但脚本仍然继续并最终崩溃,因为文件没有构建。 水管工停止了工作,我的文件没有被移动到“build”文件夹中。
管理所有这些的好方法是什么?
提前谢谢