Skip to content

Commit

Permalink
Fix handling of build flag and empty env
Browse files Browse the repository at this point in the history
`./scripts/build.js --libsass_ext=auto` resets `libsass_*` whereas it should not.
This patch drops the env vars that have not been set at all.
  • Loading branch information
kapouer committed Aug 15, 2019
1 parent 2513e6a commit fdc890f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scripts/build.js
Expand Up @@ -56,10 +56,18 @@ function afterBuild(options) {
*/

function build(options) {
var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat(
['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) {
return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
})).concat(options.args);
var libargs = ['ext', 'cflags', 'ldflags', 'library'].reduce(function(prev, cur) {
var arg = `libsass_${cur}`;
var env = process.env[arg.toUpperCase()];
if (env) {
return prev.push(['--', arg, '=', env].join(''));
} else {
return prev;
}
}, []);
var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose']
.concat(libargs)
.concat(options.args);

console.log('Building:', [process.execPath].concat(args).join(' '));

Expand Down

0 comments on commit fdc890f

Please sign in to comment.