Prevent options leaking between compilations

Currently options are leaking between compilation runs. This is most
evident when using an array of importers. The array is shallow copied
internally, and the children of that array are wrapped by Node Sass.

When the next file is compiled the options are shallow copied once
again however this time the importer array contains the wrapped
importers not the original ones.

Instead of shallow copying with `Object.assign` this patch does a
full deep clone. Node Sass should also do this to prevent mutating
the options being passed in.

Related sass/node-sass#1168
Fixes #467 (probably)
This commit is contained in:
xzyfer 2016-06-15 20:37:01 +10:00
parent 05f4cdf10f
commit 035b759f51
2 changed files with 3 additions and 3 deletions

View file

@ -2,7 +2,7 @@
var gutil = require('gulp-util'); var gutil = require('gulp-util');
var through = require('through2'); var through = require('through2');
var assign = require('object-assign'); var clonedeep = require('lodash.clonedeep');
var path = require('path'); var path = require('path');
var applySourceMap = require('vinyl-sourcemaps-apply'); var applySourceMap = require('vinyl-sourcemaps-apply');
@ -34,7 +34,7 @@ var gulpSass = function gulpSass(options, sync) {
} }
opts = assign({}, options); opts = clonedeep(options || {});
opts.data = file.contents.toString(); opts.data = file.contents.toString();
// we set the file path here so that libsass can correctly resolve import paths // we set the file path here so that libsass can correctly resolve import paths

View file

@ -22,8 +22,8 @@
}, },
"dependencies": { "dependencies": {
"gulp-util": "^3.0", "gulp-util": "^3.0",
"lodash.clonedeep": "^4.3.2",
"node-sass": "^3.4.2", "node-sass": "^3.4.2",
"object-assign": "^4.0.1",
"through2": "^2.0.0", "through2": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.0" "vinyl-sourcemaps-apply": "^0.2.0"
}, },