fix: Throw when config file does not exist (#1156)

Co-authored-by: kongmoumou <kongmoumou@users.noreply.github.com>
This commit is contained in:
kongmoumou
2024-11-13 21:59:49 +08:00
committed by GitHub
parent 199f330324
commit aa14676f91
3 changed files with 17 additions and 0 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 164 KiB

@@ -157,4 +157,18 @@ describe('User Config', () => {
await project.fileExists('.output/test-chrome-mv3-development-dev-build'),
).toBe(true);
});
it('should throw error when config file not exist', async () => {
const project = new TestProject();
project.addFile(
'src/entrypoints/background.ts',
`export default defineBackground(
() => console.log('Hello background'),
);`,
);
await expect(
project.build({ configFile: 'foo.config.ts' }),
).rejects.toThrowError(/not found/);
});
});
+3
View File
@@ -53,6 +53,9 @@ export async function resolveConfig(
esmResolve: true,
},
});
if (inlineConfig.configFile && metadata.layers?.length === 0) {
throw Error(`Config file "${inlineConfig.configFile}" not found`);
}
userConfig = loadedConfig ?? {};
userConfigMetadata = metadata;
}