Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
Warn in console if no rules are passed
Browse files Browse the repository at this point in the history
  • Loading branch information
gregives committed Dec 21, 2020
1 parent 734805a commit 507a58b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EleventyLoad {
acc[util] = utils[util].bind(this);
return acc;
}, {}),
config: context._config
config: context._config,
};

// Use input path as dependency
Expand All @@ -36,9 +36,9 @@ class EleventyLoad {

const resolvedDirectory = dependentResource.resource
? path.resolve(
this.context.config.inputDir,
path.parse(dependentResource.resourcePath).dir
)
this.context.config.inputDir,
path.parse(dependentResource.resourcePath).dir
)
: this.context.config.inputDir;

// Resolve resource for consistency
Expand Down Expand Up @@ -120,15 +120,27 @@ class EleventyLoad {
}

module.exports = function (config, options) {
const cache = {}
if (!(options.rules instanceof Array)) {
console.warn(
[
"======================================",
" Try giving eleventy-load some rules! ",
"======================================",
"",
].join("\n")
);
return;
}

const cache = {};

// Transform is our entry point
config.addTransform("eleventy-load", function (content) {
return new EleventyLoad(options, cache, content, this)
return new EleventyLoad(options, cache, content, this);
});

// Clear cache on re-runs
config.on('beforeWatch', () => {
config.on("beforeWatch", () => {
for (const resource in cache) {
delete cache[resource];
}
Expand Down

0 comments on commit 507a58b

Please sign in to comment.