Skip to content

Commit

Permalink
Merge pull request #40 from 1000ch/dev
Browse files Browse the repository at this point in the history
Catch css parsing error
  • Loading branch information
t32k committed Mar 25, 2014
2 parents 8fad660 + 07b8e13 commit 82b9051
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/cli.js
Expand Up @@ -64,10 +64,7 @@ if (!program.args.length) {
}

var stats = new StyleStats(program.args, program.config);
stats.parse(function(error, result) {
if (error) {
throw error;
}
stats.parse(function(result) {
switch (program.extension) {
case 'json':
var json = JSON.stringify(result, null, 2);
Expand Down
8 changes: 7 additions & 1 deletion lib/parser.js
Expand Up @@ -89,7 +89,13 @@ Parser.prototype.parse = function (callback) {
result.cssSize = Buffer.byteLength(result.cssString, 'utf8');

// parse css string
var rawRules = cssParse(result.cssString).stylesheet.rules;
var rawRules = [];

try {
rawRules = cssParse(result.cssString).stylesheet.rules;
} catch (e) {
throw e;
}

// add rules into result
rawRules.forEach(function(rule) {
Expand Down

0 comments on commit 82b9051

Please sign in to comment.