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;
1313Gulp . prototype . dest = vfs . dest ;
1414Gulp . prototype . symlink = vfs . symlink ;
1515Gulp . 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+
1623 if ( typeof opt === 'function' ) {
1724 task = opt ;
1825 opt = null ;
Original file line number Diff line number Diff line change @@ -126,5 +126,29 @@ describe('gulp', function() {
126126 updateTempFile ( tempFile ) ;
127127 } ) ;
128128
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+
129153 } ) ;
130154} ) ;
You can’t perform that action at this time.
0 commit comments