我的目标是在 gulp 的帮助下通过代表我在终端上执行“clasp push”来自动推送文件。
当我在 gulpfile.js 中编写以下内容时出现此错误
const gulp = require("gulp");
const exec = require("child_process");
gulp.task('push', function () {
exec("clasp push")
});
gulp.task('watch', function () {
gulp.watch([
'**/* .js',
"**/* .html"
], ['push'])
});
gulp.task('default', ['watch']);
错误:
Task function must be specified
at Gulp.set [as _setTask] (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/node_modules/undertaker/lib/set-task.js:10:3)
at Gulp.task (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/node_modules/undertaker/lib/task.js:13:8)
at Object.<anonymous> (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/gulpfile.js:15:6)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
然后我意识到我正在使用 Gulp 版本 4.0.0
然后我将代码更改为以下代码:与 Gulp V 4.0.0 兼容
const gulp = require("gulp");
const exec = require("child_process");
gulp.task('push', gulp.series('', function(){
exec("clasp push")
}));
gulp.task('watch', gulp.series('push',function () {
gulp.watch([
'**/* .js',
"**/* .html"
])
}));
gulp.task('default', gulp.series('watch', function(){
gulp.watch([
'**/* .js',
"**/* .html"
]);
}));
但后来我仍然得到这个错误:
assert.js:350 抛出错误;^
AssertionError [ERR_ASSERTION]: Task never defined: at getFunction (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/node_modules/undertaker/lib/helpers/normalizeArgs.js:15:5) at map (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/node_modules/arr-map/index.js:20:14) at normalizeArgs (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/node_modules/undertaker/lib/helpers/normalizeArgs.js:22:10) at Gulp.series (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/node_modules/undertaker/lib/series.js:13:14) at Object.<anonymous> (/Users/micklo/Desktop/AppsScriptProjects/AppsScriptAppName/gulpfile.js:4:24) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3)
我究竟做错了什么?
一些信息:
操作系统:Mac Os(莫哈韦沙漠)
Gulp 版本 -> CLI 版本:2.1.0,本地版本:4.0.0
节点:v10.15.3
表扣:2.1.0