Skip to content
Permalink
Browse files

fix: better error if resolver returns bad file

  • Loading branch information...
tivac committed Jan 6, 2019
1 parent 60c6787 commit 513c2a9b1aa2a8745928fa2cf3ab59f20a2e83fe
Showing with 26 additions and 0 deletions.
  1. +7 −0 packages/processor/plugins/graph-nodes.js
  2. +19 −0 packages/processor/test/composition.test.js
@@ -27,6 +27,13 @@ module.exports = (css, result) => {

const dependency = opts.resolve(opts.from, parsed.source);

if(!dependency) {
throw rule.error(
`Unable to locate "${parsed.source}" from "${opts.from}"`,
{ word : parsed.source }
);
}

result.messages.push({
type : "modular-css",

@@ -50,6 +50,25 @@ describe("/processor.js", () => {
}
});

it("should fail if a composition references a non-existant file from a custom resolver", async () => {
processor = new Processor({
namer,
resolvers : [
(from, file, resolve) => `${resolve(from, file)}a`,
],
});

const file = require.resolve("./specimens/composes.css");

try {
await processor.file(file);
} catch({ message }) {
expect(message).toMatch(
`Unable to locate "./folder/folder2.css" from "${file}"`
);
}
});

it("should fail if composes isn't the first property", async () => {
try {
await processor.string(

0 comments on commit 513c2a9

Please sign in to comment.
You can’t perform that action at this time.