/ / परम के साथ एक गोल कार्य कैसे करें? - गुल

परम के साथ एक गल्प कार्य कैसे करें? - गुलदस्ता

एक टटोलने का कार्य है:

gulp.task("copy-bower-components-to-dev", function () {
gulp.src("./app/bower_components/**")
.pipe(gulp.dest("dev/bower_components"));
});

मुझे दूसरे फ़ोल्डर के लिए भी यही काम चाहिए:

gulp.task("copy-bower-components-to-prod", function () {
gulp.src("./app/bower_components/**")
.pipe(gulp.dest("prod/bower_components"));
});

लेकिन यह एक साफ कोड नहीं है; मैं परम के साथ एक gulp कार्य कैसे कर सकता हूं (इस मामले में परम एक फ़ोल्डर नाम के साथ)? अग्रिम में धन्यवाद!

उत्तर:

जवाब के लिए 2 № 1

The gulp-utils वास्तव में इसके लिए एकदम सही हैं:

var gutil = require("gulp-util");

function destination() {
return (!!gutil.env.type && gutil.env.type == "prod" ? "prod" : "dev";
}

gulp.task("copy-bower-components", function () {
return gulp.src("./app/bower_components/**")
.pipe(gulp.dest(destination() + "/bower_components"));
});

इसे लेकर चलें gulp --type=prod नए फ़ोल्डर सेट करने के लिए!


जवाब के लिए 0 № 2

आप इस प्लगइन को आज़मा सकते हैं घूंट-फोल परम के साथ फोल-टास्क चलाना।

सीएमडी से नहीं परम।

"use strict";

var gulp = require("gulp");
var clean = require("gulp-clean");
var foal = require("gulp-foal");

//use "foal.task(...)" to define a foal-task.
foal.task("clean_some", function(cleanPath) {
//"return" shall not be missed for running foal-task orderly.
return gulp.src(cleanPath)
.pipe(clean());
});

gulp.task("default", function(cb) {
//use "foal.run(...)" to run your foal-task with param.
foal.run(clean_some("test_path"), cb);
});