Skip to content

Commit da680cd

Browse files
committed
Merge branch 'brightcove-master'
2 parents c017cac + 179ed4b commit da680cd

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

index.js

Lines changed: 6 additions & 3 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ 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+
});
37+
38+
node.render({
39+
data: 'html{font-size: 10px}@import "CSS:doesntexist";',
40+
importer: cssImporter({import_paths: [__dirname]})
41+
}, function(err, actual) {
42+
assert.notEqual(err, null);
43+
assert.equal(err.message.slice(0, 29), 'Specified CSS file not found!');
44+
});

0 commit comments

Comments
 (0)