-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds upgrade helper for 11ty/eleventy#3302
- Loading branch information
Showing
5 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const chalk = require("kleur"); | ||
const pkg = require("../package.json"); | ||
|
||
module.exports = function(eleventyConfig) { | ||
eleventyConfig.on("eleventy.config", templateConfig => { | ||
let templateFormatsActive = templateConfig.templateFormats.getTemplateFormats(); | ||
|
||
if(eleventyConfig.extensionMap.size === 0) { | ||
console.log(chalk.green(`[${pkg.name}] PASSED`), `No aliases were added via \`eleventyConfig.addExtension()\`. If you had added an alias, it would need to be also added to your active template formats. Learn more about template formats: https://www.11ty.dev/docs/config/#template-formats or about this change: https://github.com/11ty/eleventy/issues/3302`); | ||
} else { | ||
for(let { key, extension, aliasKey } of eleventyConfig.extensionMap) { | ||
if(!templateFormatsActive.includes(extension)) { | ||
console.log(chalk.red(`[${pkg.name}] ERROR`), `Aliases added via \`eleventyConfig.addExtension()\` must be added to your active template formats, via \`--formats=${extension}\` on the command line, the \`templateFormats: "${extension}"\` configuration object property, \`eleventyConfig.setTemplateFormats("${extension}")\`, or \`eleventyConfig.addTemplateFormats("${extension}")\` (additive). This *might* be what you want if you added a plugin but don’t want to currently process ${extension} files in Eleventy. Learn more about template formats: https://www.11ty.dev/docs/config/#template-formats or about this change: https://github.com/11ty/eleventy/issues/3302`); | ||
} else { | ||
console.log(chalk.green(`[${pkg.name}] PASSED`), `\`${extension}\` is an active template format, referenced as an alias via \`eleventyConfig.addExtension()\`. Learn more about template formats: https://www.11ty.dev/docs/config/#template-formats or about this change: https://github.com/11ty/eleventy/issues/3302`); | ||
} | ||
} | ||
|
||
} | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters