Skip to content

Commit 31432de

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

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

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

+4-23
Original file line numberDiff line numberDiff line change
@@ -124,31 +124,12 @@ export default async (dir: string): Promise<ResolvedForgeConfig> => {
124124
forgeConfig = packageJSON.config && packageJSON.config.forge ? packageJSON.config.forge : null;
125125
}
126126

127-
if (!forgeConfig || typeof forgeConfig === 'string') {
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);
127+
if (!forgeConfig || !['object', 'string'].includes(typeof forgeConfig)) {
128+
for (const extension of ['.js', ...Object.keys(interpret.extensions)]) {
129+
const pathToConfig = path.resolve(dir, `forge.config${extension}`);
149130
if (await fs.pathExists(pathToConfig)) {
150131
rechoir.prepare(interpret.extensions, pathToConfig, dir);
151-
forgeConfig = file;
132+
forgeConfig = `forge.config${extension}`;
152133
break;
153134
}
154135
}

0 commit comments

Comments
 (0)