Skip to content

Commit 8025bbc

Browse files
committed
Fix bug preventing import of files with dots in their name
Closes #11
1 parent 4fe5ad0 commit 8025bbc

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var importOnce = function importOnce(data, done) {
4242
* they leave off the partial prefix and the suffix.
4343
* This code creates the possible extensions, whether it is a partial
4444
* and whether it is a directory index file having those
45-
* same possible variations. If the import contains an extension,
45+
* same possible variations. If the import contains a valid extension,
4646
* then it is left alone.
4747
*
4848
**/
@@ -51,7 +51,7 @@ var getFileNames = function getFileNames(abstractName) {
5151
directory,
5252
basename;
5353

54-
if (path.extname(abstractName)) {
54+
if ([ '.scss', '.sass', '.css', '.json', '.yaml' ].indexOf(path.extname(abstractName)) !== -1) {
5555
names.push(abstractName);
5656
}
5757
else {

test/css/import-with-dot.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.some-class-in-dotted-file {
2+
color: blue; }

test/main.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,27 @@ describe('import-once', function () {
267267
done();
268268
});
269269
});
270+
271+
it('should import a file with dots in its name', function(done) {
272+
var file = filePath('import-with-dot.scss'),
273+
expectedIncludes = [
274+
file,
275+
filePath('file.with.dot.scss')
276+
];
277+
278+
sass.render({
279+
'file': file,
280+
'importer': importer
281+
}, function(err, result) {
282+
if (err) {
283+
throw err;
284+
}
285+
should.exist(result);
286+
result.stats.includedFiles.should.eql(expectedIncludes);
287+
String(result.css).should.equal(
288+
fs.readFileSync(path.join(__dirname, 'css/import-with-dot.css'), 'utf8')
289+
);
290+
done();
291+
});
292+
});
270293
});

test/sass/file.with.dot.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.some-class-in-dotted-file {
2+
color: blue;
3+
}

test/sass/import-with-dot.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "file.with.dot";

0 commit comments

Comments
 (0)