Skip to content

Commit b43e4e7

Browse files
author
jrivera
committed
All paths now call done with either success or with an error if one was generated
1 parent c017cac commit b43e4e7

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function(options) {
66

77
var import_paths
88
, import_paths_len;
9-
9+
1010
return function(url, prev, done) {
1111
if (url.slice(0, 4) !== 'CSS:') {
1212
return done();
@@ -30,11 +30,14 @@ module.exports = function(options) {
3030
css_filepath = path.join(import_path, css_path);
3131
if (fs.existsSync(css_filepath)) {
3232
fs.readFile(css_filepath, function(err, data) {
33-
if (err) return console.error(err);
33+
if (err) {
34+
return done(err);
35+
}
3436
done({contents: data.toString()});
3537
});
36-
break;
38+
return;
3739
}
3840
}
41+
return done(new Error('Specified CSS file not found! ("' + css_path + '" referenced from "' + prev + '")'));
3942
};
4043
};

test/badsource.scss

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
html {
2+
font-size: 10px;
3+
}
4+
5+
@import "CSS:doesntexist";

test/test.js

+8
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@ node.render({
2626
assert.equal(actual.css.toString(), expected.toString());
2727
});
2828
});
29+
30+
node.render({
31+
file: path.join(__dirname, 'badsource.scss'),
32+
importer: cssImporter({import_paths: [__dirname]})
33+
}, function(err, actual) {
34+
assert.notEqual(err, null);
35+
assert.equal(err.message.slice(0, 29), 'Specified CSS file not found!');
36+
});

0 commit comments

Comments
 (0)