Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"postcss-less": "^3.1.0",
"postcss-markdown": ">=0.36.0",
"postcss-safe-parser": "^4.0.1",
"postcss-sass": "^0.4.4",
"postcss-scss": "^2.0.0",
"proxyquire": "^2.1.0",
"sugarss": "^2.0.0"
Expand Down
9 changes: 8 additions & 1 deletion patch-postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ function patchNode (Node) {
Node = Node.prototype;
const NodeToString = Node.toString;
Node.toString = function toString (stringifier) {
return NodeToString.call(this, stringifier || this.root().source.syntax);
let arg = stringifier;
if (!arg) {
const source = this.root().source;
if (source) {
arg = source.syntax;
}
}
return NodeToString.call(this, arg);
};
}

Expand Down
29 changes: 29 additions & 0 deletions test/sass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
const postcss = require("postcss");
const expect = require("chai").expect;
const syntax = require("../")({
css: "sass",
});

describe("sass", () => {
it("test", () => {
const sass = `
$sizes: 40px, 50px, 80px
@each $size in $sizes
.icon-#{$size}
font-size: $size
`.trim();
return postcss([
function (root) {
root.nodes.forEach(node => {
node.toString();
});
}
]).process(sass, {
syntax,
from: 'style.sass',
}).then(result => {
expect(result.css).to.equal(sass);
});
});
})