From 62d41ab6bad9a4afbe94e52caf47fb2032c83e10 Mon Sep 17 00:00:00 2001 From: RyanZim Date: Thu, 17 Nov 2016 15:28:48 -0500 Subject: [PATCH] BREAKING: File not found is an Error, not a Warning --- index.js | 1 + test/import.js | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index e8a7deb8..0a484905 100755 --- a/index.js +++ b/index.js @@ -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 }) }) } diff --git a/test/import.js b/test/import.js index 857ae69a..1c07717b 100644 --- a/test/import.js +++ b/test/import.js @@ -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) }) })