Skip to content

Commit

Permalink
Add more logging to injected config
Browse files Browse the repository at this point in the history
  • Loading branch information
rphillips-nz committed Oct 20, 2021
1 parent 70199a6 commit c36ae8e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/inject-cloudcannon.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
const pluginCloudCannon = require('eleventy-plugin-cloudcannon');

let defaultConfig;

try {
defaultConfig = require('./default-eleventy.config.js');
} catch (e) {
console.error('⚠️ Unable to require your config from eleventy-plugin-cloudcannon:', e);
}

// Used when the 'Manage eleventy-plugin-cloudcannon manually' option is disabled in CloudCannon.
// Adds this plugin after running the renamed default config file.
module.exports = function (eleventyConfig, ...args) {
let defaultConfig;

try {
defaultConfig = require('./default-eleventy.config.js');
} catch {
console.error('Not found: ./default-eleventy.config.js');
}

console.log('🔮 Starting automatic eleventy-plugin-cloudcannon');
const config = defaultConfig?.apply?.(this, [eleventyConfig, ...args]) ?? {};
console.log('☑️ Processed default configuration for eleventy-plugin-cloudcannon');
eleventyConfig.addPlugin(pluginCloudCannon, eleventyConfig.cloudcannonOptions ?? config);
console.log('☑️ Finished eleventy-plugin-cloudcannon');
return config;
};

0 comments on commit c36ae8e

Please sign in to comment.