gulp-preprocess and environment variables on Windows 10 -


i building js app on osx, , windows 10, both running node.js v4.2.x.

as part of build process run

build_type={my-build-type} gulp build 

which builds particular configuration of app, using gulp-preprocess.

the relevant part of gulp file looks like

var env = process.env;  ... .pipe(plug.preprocess({context: { build_type: env.build_type}})) ... 

the relevant part of html looks like

<!-- @if build_type='live' -->     <script src="config/live.js"></script> <!-- @endif -->  <!-- @if build_type='dev' -->     <script src="config/dev.js"></script> <!-- @endif -->  <!-- @ifndef build_type -->     <script src="config/dev.js"></script> <!-- @endif -->  <p>build type - <!-- @echo build_type --></p> 

on osx works great, running build_type=dev gulp build results in:

<script src="config/dev.js"></script>  <p>build type - dev</p> 

however, on windows 10, using node.js command prompt,

set build_type=dev && gulp build  

results in:

<p>build type - dev</p> 

with no script tags appearing! it's recognised environment variable, it's printed @echo build_type. however, none of script elements present.

any clues why might happening appreciated!

oddly, if change gulpfile to:

... .pipe(plug.preprocess({context: { build_type: 'dev'}})) ... 

i expected output:

<script src="config/dev.js"></script>  <p>build type - dev</p> 

further still, if log variable before invoking preprocess:

osx

console.log(env.build_type); //dev console.log(typeof env.build_type); //string console.log(env.build_type === 'dev'); //true 

windows 10

console.log(env.build_type); //dev console.log(typeof env.build_type); //string console.log(env.build_type === 'dev'); //false! 

have ensured setting environment variable using no spaces after defining it.

something like:

set build_type=dev&&gulp build


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -