Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only call .toString() on sass files #47

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 45 additions & 41 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
},

compile = function(config, basePath, files, filename, done) {
if (isPartial(filename)) {
delete files[filename];
done();
return;
}

if (!isAnySassFile(filename)) {
done();
return;
}

var file = files[filename],
filePath = path.join(basePath, filename),
opts = extend({
Expand All @@ -57,54 +68,47 @@
opts.outFile = filePath.replace(/\.s[ca]ss/, '.css');
}

if (isAnySassFile(filename) === true) {
// Append the file's base path to the available include paths.
opts.includePaths.push(fileDir);

// Compile the file using SASS.
sass.render(opts, function (err, result) {
var error = null;

if (err && err instanceof Error) {
error = new Error([
'[metalsmith-sass] Error: ',
err.message, ' -> ',
err.file,
':',
err.line, ':', err.column
].join(''));
} else if (err) {
error = new Error(err);
}
// Append the file's base path to the available include paths.
opts.includePaths.push(fileDir);

// Compile the file using SASS.
sass.render(opts, function (err, result) {
var error = null;

if (err && err instanceof Error) {
error = new Error([
'[metalsmith-sass] Error: ',
err.message, ' -> ',
err.file,
':',
err.line, ':', err.column
].join(''));
} else if (err) {
error = new Error(err);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just indentation changes due to the inversion of the if statement.


if (error) {
done(error);
return;
}
if (error) {
done(error);
return;
}

// add soure map
if (result.map) {
files[dest+'.map'] = {
contents: result.map,
mode: file.mode
};
}
// add soure map
if (result.map) {
files[dest+'.map'] = {
contents: result.map,
mode: file.mode
};
}

// replace contents
file.contents = result.css;
// replace contents
file.contents = result.css;

// rename file extension
files[dest] = file;
// rename file extension
files[dest] = file;

delete files[filename];
done();
});
} else if (isPartial(filename) === true) {
delete files[filename];
done();
} else {
done();
}
});
},

compileSass = function compileSass(config, files, metalsmith, done) {
Expand Down