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

BREAKING: File not found is an Error, not a Warning #247

Merged
merged 1 commit into from
Nov 17, 2016
Merged
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 index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ function resolveImportId(
}, [])
})
.catch(function(err) {
if (err.message.indexOf("Failed to find") !== -1) throw err
result.warn(err.message, { node: atRule })
})
}
Expand Down
12 changes: 4 additions & 8 deletions test/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,14 @@ test("should not fail with absolute and local import", t => {
})
})

test("should output readable trace", t => {
test("should error when file not found", t => {
t.plan(1)
var file = "fixtures/imports/import-missing.css"
return postcss()
.use(atImport())
.process(readFileSync(file), { from: file })
.then(result => {
t.is(
result.warnings()[0].text,
/* eslint-disable max-len */
"Failed to find 'missing-file.css'\n in [ \n " + path.resolve("fixtures/imports") + "\n ]"
/* eslint-enabme max-len */
)
.catch(err => {
t.truthy(err)
})
})

Expand Down