diff --git a/index.js b/index.js index 700520d..9d0fc67 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,7 @@ var importOnce = function importOnce(data, done) { * they leave off the partial prefix and the suffix. * This code creates the possible extensions, whether it is a partial * and whether it is a directory index file having those - * same possible variations. If the import contains an extension, + * same possible variations. If the import contains a valid extension, * then it is left alone. * **/ @@ -51,7 +51,7 @@ var getFileNames = function getFileNames(abstractName) { directory, basename; - if (path.extname(abstractName)) { + if ([ '.scss', '.sass', '.css', '.json', '.yaml' ].indexOf(path.extname(abstractName)) !== -1) { names.push(abstractName); } else { diff --git a/test/css/import-with-dot.css b/test/css/import-with-dot.css new file mode 100644 index 0000000..4606e41 --- /dev/null +++ b/test/css/import-with-dot.css @@ -0,0 +1,2 @@ +.some-class-in-dotted-file { + color: blue; } diff --git a/test/main.js b/test/main.js index 12fd23c..b152817 100644 --- a/test/main.js +++ b/test/main.js @@ -267,4 +267,27 @@ describe('import-once', function () { done(); }); }); + + it('should import a file with dots in its name', function(done) { + var file = filePath('import-with-dot.scss'), + expectedIncludes = [ + file, + filePath('file.with.dot.scss') + ]; + + sass.render({ + 'file': file, + 'importer': importer + }, function(err, result) { + if (err) { + throw err; + } + should.exist(result); + result.stats.includedFiles.should.eql(expectedIncludes); + String(result.css).should.equal( + fs.readFileSync(path.join(__dirname, 'css/import-with-dot.css'), 'utf8') + ); + done(); + }); + }); }); diff --git a/test/sass/file.with.dot.scss b/test/sass/file.with.dot.scss new file mode 100644 index 0000000..7f65038 --- /dev/null +++ b/test/sass/file.with.dot.scss @@ -0,0 +1,3 @@ +.some-class-in-dotted-file { + color: blue; +} diff --git a/test/sass/import-with-dot.scss b/test/sass/import-with-dot.scss new file mode 100644 index 0000000..666fb1f --- /dev/null +++ b/test/sass/import-with-dot.scss @@ -0,0 +1 @@ +@import "file.with.dot";