Skip to content

Commit e9382ac

Browse files
committed
Front-load the file extension warning
1 parent 7781abd commit e9382ac

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/set-pages-config.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,23 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit
7777

7878
// Inject Pages configuration in a given static site generator's configuration file
7979
function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
80+
const isSupportedFileExtension = SUPPORTED_FILE_EXTENSIONS.some(ext => generatorConfigFile.endsWith(ext))
81+
if (generatorConfigFile && !isSupportedFileExtension) {
82+
const supportedExtensionList = SUPPORTED_FILE_EXTENSIONS.map(ext => JSON.stringify(ext)).join(', ')
83+
core.warning(
84+
`Unsupported extension in configuration file: ${generatorConfigFile}. Currently supported extensions: ${supportedExtensionList}. We will still attempt to inject the site metadata into the configuration file, but it may not work as expected.`
85+
)
86+
}
87+
8088
try {
8189
// Parse the configuration file and try to inject the Pages configuration in it
8290
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl })
8391
new ConfigParser(settings).injectAll()
8492
} catch (error) {
85-
const isSupportedFileExtension = SUPPORTED_FILE_EXTENSIONS.some(ext => generatorConfigFile.endsWith(ext))
86-
87-
// Logging
88-
if (!isSupportedFileExtension) {
89-
core.warning(
90-
`Unsupported configuration file extension. Currently supported extensions: ${SUPPORTED_FILE_EXTENSIONS.map(
91-
ext => JSON.stringify(ext)
92-
).join(', ')}. Error: ${error.message}`,
93-
convertErrorToAnnotationProperties(error)
94-
)
95-
} else {
96-
core.warning(
97-
`We were unable to determine how to inject the site metadata into your config. Generated URLs may be incorrect. The base URL for this site should be ${siteUrl}. Please ensure your framework is configured to generate relative links appropriately. Error: ${error.message}`,
98-
convertErrorToAnnotationProperties(error)
99-
)
100-
}
93+
core.warning(
94+
`We were unable to determine how to inject the site metadata into your config. Generated URLs may be incorrect. The base URL for this site should be ${siteUrl}. Please ensure your framework is configured to generate relative links appropriately. Error: ${error.message}`,
95+
convertErrorToAnnotationProperties(error)
96+
)
10197
}
10298
}
10399

0 commit comments

Comments
 (0)