Skip to content

Commit 5775c61

Browse files
committed
fix(api-core): find forgeConfig file
1 parent 1193d15 commit 5775c61

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

packages/api/core/src/util/forge-config.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,30 @@ export default async (dir: string): Promise<ResolvedForgeConfig> => {
125125
}
126126

127127
if (!forgeConfig || typeof forgeConfig === 'string') {
128-
for (const extension of ['.js', ...Object.keys(interpret.extensions)]) {
129-
const pathToConfig = path.resolve(dir, `forge.config${extension}`);
128+
const iterator = (() => {
129+
const file = typeof forgeConfig === 'string' ? forgeConfig : false;
130+
const extensions = ['.js', ...Object.keys(interpret.extensions)];
131+
let index = -1;
132+
return {
133+
[Symbol.iterator]: () => ({
134+
next() {
135+
if (index >= extensions.length) return { done: true, value: '' };
136+
let value: string | false;
137+
if (index < 0) {
138+
index = 0;
139+
value = file;
140+
}
141+
value ||= `forge.config${extensions[index++]}`;
142+
return { value };
143+
},
144+
}),
145+
};
146+
})();
147+
for (const file of iterator) {
148+
const pathToConfig = path.resolve(dir, file);
130149
if (await fs.pathExists(pathToConfig)) {
131150
rechoir.prepare(interpret.extensions, pathToConfig, dir);
132-
forgeConfig = `forge.config${extension}`;
151+
forgeConfig = file;
133152
break;
134153
}
135154
}

0 commit comments

Comments
 (0)