Skip to content

Commit

Permalink
BREAKING: CssSyntaxError in imported file now throws instead of warns
Browse files Browse the repository at this point in the history
Closes #264
  • Loading branch information
RyanZim committed Aug 25, 2017
1 parent a993d1a commit 86ccbdb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ function resolveImportId(result, stmt, options, state) {
return statements ? result.concat(statements) : result
}, [])
})
.catch(err => {
if (err.message.indexOf("Failed to find") !== -1) throw err
result.warn(err.message, { node: atRule })
})
}

function loadImportContent(result, stmt, filename, options, state) {
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/imports/syntax-error.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
bar: bar;
qux: qux;

a {
foo: foo;
}
6 changes: 6 additions & 0 deletions test/fixtures/syntax-error.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import "syntax-error.css";

syntax.error {
/* Error isn't here, it's in the imported file */
color: green;
}
16 changes: 16 additions & 0 deletions test/syntax-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// builtin tooling
import fs from "fs"

// external tooling
import test from "ava"
import postcss from "postcss"

// plugin
import atImport from ".."

test("SyntaxError in imported file throws", t => {
return postcss(atImport({ path: "test/fixtures/imports" }))
.process(fs.readFileSync("test/fixtures/syntax-error.css", "utf8"))
.then(() => t.fail("should error out"))
.catch(err => t.truthy(err))
})

0 comments on commit 86ccbdb

Please sign in to comment.