Reputation: 1375
I have the following gulpfile.js. The new_version
task creates a new version directory in the source code.
const { src, dest } = require('gulp');
const fs = require('fs');
const minify = require('gulp-minify');
const del = require('del');
var PACKAGE = require('./package.json');
var version = PACKAGE.version;
var itb_version = PACKAGE.itb_version;
var name = PACKAGE.name;
var distPath = "./dist/" + version + "/js";
function clean() {
return del('dist/**', {force:true});
}
function new_version() {
return clean()
.pipe(function() {
if(!fs.existsSync(itb_version)) {
fs.mkdirSync(itb_version);
}
});
}
function build() {
return src('./src/myfile.js')
.pipe(minify({
ext:{
min:'.min.js'
}
}))
.pipe(dest(distPath));
}
exports.clean = clean;
exports.new_version = new_version;
exports.build = build;
When I run gulp new_version
I get the following error:
[10:44:50] Using gulpfile ~/projects/myproject/gulpfile.js
[10:44:50] Starting 'new_version'...
[10:44:50] 'new_version' errored after 3.14 ms
[10:44:50] TypeError: clean(...).pipe is not a function
What am I doing wrong here?
Upvotes: 1
Views: 2367
Reputation: 182121
del()
returns a Promise not a stream, see del docs and pipe() is not a function of a Promise. Just call your clean
function as part of a series
. [code below not tested]
const { src, dest, series } = require('gulp');
...
exports.new_version = gulp.series(clean, new_version);
function new_version() {
if(!fs.existsSync(itb_version)) {
fs.mkdirSync(itb_version);
}
}
Upvotes: 2