File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ Gulp.prototype.src = vfs.src;
13
13
Gulp . prototype . dest = vfs . dest ;
14
14
Gulp . prototype . symlink = vfs . symlink ;
15
15
Gulp . prototype . watch = function ( glob , opt , task ) {
16
+ if ( typeof opt === 'string' || typeof task === 'string' ||
17
+ Array . isArray ( opt ) || Array . isArray ( task ) ) {
18
+ throw new Error ( 'watching ' + glob + ': watch task has to be ' +
19
+ 'a function (optionally generated by using gulp.parallel ' +
20
+ 'or gulp.series)' ) ;
21
+ }
22
+
16
23
if ( typeof opt === 'function' ) {
17
24
task = opt ;
18
25
opt = null ;
Original file line number Diff line number Diff line change @@ -126,5 +126,29 @@ describe('gulp', function() {
126
126
updateTempFile ( tempFile ) ;
127
127
} ) ;
128
128
129
+ it ( 'should throw an error: passed parameter (string) is not a function' , function ( done ) {
130
+ var tempFile = path . join ( outpath , 'empty.txt' ) ;
131
+
132
+ createTempFile ( tempFile ) ;
133
+ try {
134
+ gulp . watch ( tempFile , 'task1' ) ;
135
+ } catch ( err ) {
136
+ err . message . should . equal ( 'watching ' + tempFile + ': watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)' ) ;
137
+ done ( ) ;
138
+ }
139
+ } ) ;
140
+
141
+ it ( 'should throw an error: passed parameter (array) is not a function' , function ( done ) {
142
+ var tempFile = path . join ( outpath , 'empty.txt' ) ;
143
+
144
+ createTempFile ( tempFile ) ;
145
+ try {
146
+ gulp . watch ( tempFile , [ 'task1' ] ) ;
147
+ } catch ( err ) {
148
+ err . message . should . equal ( 'watching ' + tempFile + ': watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)' ) ;
149
+ done ( ) ;
150
+ }
151
+ } ) ;
152
+
129
153
} ) ;
130
154
} ) ;
You can’t perform that action at this time.
0 commit comments