gunpowderlabs / gulp-environments Goto Github PK
View Code? Open in Web Editor NEWA library for conditionally executing code in Gulp depending on an environment.
A library for conditionally executing code in Gulp depending on an environment.
nmp install --save-dev gulp-environments
Should be:
npm install --save-dev gulp-environments
I wanted to create 2 environments, based on my process.env.HOST variable, which should be either "live" or "dev".
var environments = require('gulp-environments');
var liveOnly = environments.make('live');
var devOnly = environments.make('dev');
environments.current(process.env.HOST);
console.log(liveOnly?true:false,devOnly?true:false)
This is on my dev environment, and I know process.env.HOST resolves to "dev". But in the above example, the console logs true true
, which according to your docs indicates that both environments are active? Maybe I'm misunderstanding what "active" means, but I took it to mean it's set as the current task.
Also if I use console.log(liveOnly(),devOnly())
i instead get false false
, not sure what that's about.
The latest version of this uses "yargs": "^5.0.0"
which contains vulnerabilities (uses yargs-parser
version 3.2.0
). Requesting that the yargs
dependency is updated to the latest.
vulnerability description: https://snyk.io/vuln/npm:yargs-parser
I want to be able to output the currently defined environment as a string; environments.current()
should return "development"
npm install [email protected]
installs [email protected]
, which uses [email protected]. Producing the following error message:
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
I would love to have the ability to do an inline check for production
or staging
in my gulp tasks, maybe something like the following:
...
.pipe(environments.in(['production', 'staging'], uglify()))
...or...
.pipe(environments.not(['production', 'staging'], uglify()))
...
Is there currently a supported way of doing this?
I have files that are supposed to be compiled to temp
folder if the NODE_ENV
value is development
; otherwise, to app
folder.
I've tried these 4 ways but all failed:
// the $ sign is gulpLoadPlugins()
const isDev = $.environments.development;
const isProd = $.environments.production;
As what the docs instructed
.pipe(isDev() ? gulp.dest('temp') : gulp.dest('app'))
With gulp-if
.pipe($.if(isDev(), gulp.dest('temp'), gulp.dest('app')))
Processing the condition inside the gulp.dest()
method
.pipe(gulp.dest(isDev() ? 'temp' : 'app'))
Both condition piped
.pipe(isDev(gulp.dest('temp')))
.pipe(isProd(gulp.dest('app')))
THE RESULT:
Both NODE_ENV
values compile files to the same folder.
Removing the parentheses after isDev
doesn't solve the problem either.
This would save a lot of typing in the CLI when in development. I would argue it's also the expected behavior.
Given the line current(make(process.env.NODE_ENV || argv.env || "development"));
if NODE_ENV is set to anything truthy it'll use that regardless of any other method (as the or is short-circuited) of setting the environment, and otherwise it'll fall to arg.env in the same way, and so forth. Make this clear in the documentation. Also, if NODE_ENV is set to "development" then not even gulp.task('set-prod', production.task);
or environments.current(production);
will override it
Plus, I think it should be reversed, command line should override NODE_ENV or code, and code should override NODE_ENV.
Thanks for the module!
If I have two tasks written in the default Gulp 4 export mode (task()
is deprecated), in example:
exports.development = parallel(css, js, img, fonts, icons);
exports.production = parallel(css, js, img, fonts, icons);
how can I set the environment under which each of these exported task should run form inside the gulpfile (I don't want to use CLI flags)?
The readme says to create a task that sets the environment and run it before the others, what is the correct way to do it by using the default Gulp 4 function definition of tasks, like in the example below?
function setDev(cb) {
// body omitted
cb();
}
function setProd(cb) {
// body omitted
cb();
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.