matype/stylefmt

Cannot read property 'split' of undefined

Opened this issue · 3 comments

TypeError: Cannot read property 'split' of undefined
at declarationEmptyLineBefore (node_modules\stylefmt\lib\formatDecls.js:65:33)
at node_modules\stylefmt\lib\formatDecls.js:26:26
at node_modules\postcss\lib\container.js:192:28
at node_modules\postcss\lib\container.js:148:26
at Rule.each (node_modules\postcss\lib\container.js:114:22)
at Rule.walk (node_modules\postcss\lib\container.js:147:21)
at Rule.walkDecls (node_modules\postcss\lib\container.js:190:25)
at formatDecls (node_modules\stylefmt\lib\formatDecls.js:14:10)
at node_modules\stylefmt\lib\formatRules.js:64:12
at node_modules\postcss\lib\container.js:241:28
at node_modules\postcss\lib\container.js:148:26
at Root.each (node_modules\postcss\lib\container.js:114:22)
at Root.walk (node_modules\postcss\lib\container.js:147:21)
at Root.walkRules (node_modules\postcss\lib\container.js:239:25)
at formatRules (node_modules\stylefmt\lib\formatRules.js:11:8)
at node_modules\stylefmt\index.js:18:9

Please tell me your environment. Do you use task runner? What version of Node.js do you use? and so on

Node v7.6.0.
Don't use task runner.

fs.readFile("./tests/data/" + src, "utf8", (err, css) => { postcss([myplugin, stylefmt]).process(css).then(result => { fs.writeFileSync(dest, result.css); }); });

CSS code after my plugin: http://pastebin.com/9rfVVK46

I fixed with var nlCount = (decl.raws.before) ? decl.raws.before.split('\n').length - 1 : 0
in stylefmt\lib\formatDecls.js:65