Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Restore behaviour of cwd in include path
Browse files Browse the repository at this point in the history
Traditionally Sass has added the cwd as the first include path. This
behaviour was remove in Sass 3.4, and recently in LibSass 3.5.0.beta.2.
People depend on this behaviour and as a result a lot of compilations
are now failing.

This PR restores the expected behaviour and adds a test to boot.

Fixes #1876
  • Loading branch information
xzyfer committed Jan 31, 2017
1 parent 4271c70 commit 4310623
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ function buildIncludePaths(options) {
);
}

// Preserve the behaviour people have come to expect.
// This behaviour was removed from Sass in 3.4 and
// LibSass in 3.5.
options.includePaths.unshift(process.cwd());

return options.includePaths.join(path.delimiter);
}

Expand Down
17 changes: 17 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ describe('api', function() {
});
});

it('should add cwd to the front on include paths', function(done) {
var src = fixture('cwd-include-path/root/index.scss');
var expected = read(fixture('cwd-include-path/expected.css'), 'utf8').trim();
var cwd = process.cwd();

process.chdir(fixture('cwd-include-path'));
sass.render({
file: src,
includePaths: []
}, function(error, result) {
assert.equal(result.css.toString().trim(), expected.replace(/\r\n/g, '\n'));

process.chdir(cwd);
done();
});
});

it('should check SASS_PATH in the specified order', function(done) {
var src = read(fixture('sass-path/index.scss'), 'utf8');
var expectedRed = read(fixture('sass-path/expected-red.css'), 'utf8').trim();
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/cwd-include-path/expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.outside {
color: red; }
3 changes: 3 additions & 0 deletions test/fixtures/cwd-include-path/outside.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.outside {
color: red;
}
1 change: 1 addition & 0 deletions test/fixtures/cwd-include-path/root/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'outside';

0 comments on commit 4310623

Please # to comment.