Skip to content

Commit

Permalink
Prevent options leaking between compilations
Browse files Browse the repository at this point in the history
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 dlmanning#467 (probably)
  • Loading branch information
xzyfer committed Jun 15, 2016
1 parent 05f4cdf commit 32f694a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var gutil = require('gulp-util');
var through = require('through2');
var assign = require('object-assign');
var clonedeep = require('lodash.clonedeep');
var path = require('path');
var applySourceMap = require('vinyl-sourcemaps-apply');

Expand Down Expand Up @@ -34,7 +34,7 @@ var gulpSass = function gulpSass(options, sync) {
}


opts = assign({}, options);
opts = clonedeep(options);
opts.data = file.contents.toString();

// we set the file path here so that libsass can correctly resolve import paths
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"dependencies": {
"gulp-util": "^3.0",
"lodash.clonedeep": "^4.3.2",
"node-sass": "^3.4.2",
"object-assign": "^4.0.1",
"through2": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.0"
},
Expand Down

0 comments on commit 32f694a

Please sign in to comment.