Skip to content

Commit

Permalink
if present ts config takes precedence over js config
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmossas committed May 31, 2024
1 parent 9901d41 commit 5827694
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/main/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,34 @@ export const loadConfig = async (
}
throw new Error(`${fileName} does not exist or it is empty.`);
}
const defaultConfigs = [
const defaultConfigNames = [
'contentful-hugo.config.ts',
'contentful-hugo.config.js',
'contentful-hugo.config.yaml',
'contentful-hugo.yaml',
'contentful-settings.yaml',
];
const tasks = [];
const configList: ContentfulHugoConfig[] = [];
for (const config of defaultConfigs) {
const file = loadFile(rootDir, config).then((result) => {
const configMap: Record<string, ContentfulHugoConfig | null> = {};
for (const name of defaultConfigNames) {
const file = loadFile(rootDir, name).then((result) => {
if (result) {
const conf = checkContentfulSettings(result);
configList.push(conf);
configMap[name] = conf;
return;
}
configMap[name] = null;
});
tasks.push(file);
}
return Promise.all(tasks).then(() => {
// eslint-disable-next-line no-unreachable-loop
for (const config of configList) {
return config;
await Promise.all(tasks);
for (const filename of defaultConfigNames) {
if (configMap[filename]) {
console.log(`Using config at ${filename}`);
return configMap[filename]!;
}
return false;
});
}
return false;
};

export const defineConfig = (config: Partial<ContentfulHugoConfig>) => config;

0 comments on commit 5827694

Please sign in to comment.