diff --git a/lib/index.js b/lib/index.js index 4d880a8f5..fafbe55f2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); } diff --git a/test/api.js b/test/api.js index 8ff5a972d..67a53ccb3 100644 --- a/test/api.js +++ b/test/api.js @@ -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(); diff --git a/test/fixtures/cwd-include-path/expected.css b/test/fixtures/cwd-include-path/expected.css new file mode 100644 index 000000000..1cfd35a4a --- /dev/null +++ b/test/fixtures/cwd-include-path/expected.css @@ -0,0 +1,2 @@ +.outside { + color: red; } diff --git a/test/fixtures/cwd-include-path/outside.scss b/test/fixtures/cwd-include-path/outside.scss new file mode 100644 index 000000000..956862381 --- /dev/null +++ b/test/fixtures/cwd-include-path/outside.scss @@ -0,0 +1,3 @@ +.outside { + color: red; +} diff --git a/test/fixtures/cwd-include-path/root/index.scss b/test/fixtures/cwd-include-path/root/index.scss new file mode 100644 index 000000000..0279f783b --- /dev/null +++ b/test/fixtures/cwd-include-path/root/index.scss @@ -0,0 +1 @@ +@import 'outside';