Skip to content

Commit

Permalink
Fix bug preventing import of files with dots in their name
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
eppsilon committed Nov 19, 2015
1 parent 4fe5ad0 commit 8025bbc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
**/
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions test/css/import-with-dot.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.some-class-in-dotted-file {
color: blue; }
23 changes: 23 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
3 changes: 3 additions & 0 deletions test/sass/file.with.dot.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.some-class-in-dotted-file {
color: blue;
}
1 change: 1 addition & 0 deletions test/sass/import-with-dot.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "file.with.dot";

0 comments on commit 8025bbc

Please sign in to comment.