Skip to content

Commit

Permalink
wrap node-sass error message in Error object
Browse files Browse the repository at this point in the history
closes #15 - when using Metalsmith cli, errors are
expected to an actual error object, not a string
  • Loading branch information
stevenschobert committed Jan 30, 2015
1 parent d2f4610 commit 9a15861
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
includePaths: includes,
imagePath: imagePath,
outputStyle: outputStyle,
success: function(css) {
success: function handleSuccess(css) {
// replace contents
file.contents = new Buffer(css);
// rename file extension
files[path.join(outputDir, path.basename(filename).replace('.scss', '.css'))] = file;
delete files[filename];
done();
},
error: function(err) {
error: function handleError(err) {
if (typeof err === 'string') {
err = new Error(err);
}
done(err);
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@
});
});

it('should fail when invalid file provided', function(done) {
it('should correctly report errors to Metalsmith', function(done) {
metalsmith(__dirname)
.source('fixtures/invalid/src')
.destination('fixtures/invalid/build')
.use(sass({
outputStyle: 'expanded'
}))
.build(function (err) {
assert.notEqual(err, null, "Error should be set.");
assert(err.message && /aninvalidrule/.test(err.message));
assert(!exists(join(__dirname, 'fixtures/invalid/build/invalid.scss')));
done();
});
Expand Down

0 comments on commit 9a15861

Please sign in to comment.