Skip to content

Commit

Permalink
fix(compiler): allow to set custom root directory (#5446)
Browse files Browse the repository at this point in the history
* fix(compiler): allow to set custom root directory

* fix unit tests

* PR comment
  • Loading branch information
christian-bromann authored Mar 11, 2024
1 parent b279858 commit b6b9617
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/config/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const loadConfig = async (init: LoadConfigInit = {}): Promise<LoadConfigR
configPath = loadedConfigFile.configPath;
unknownConfig.config = { ...loadedConfigFile, ...config };
unknownConfig.config.configPath = configPath;
unknownConfig.config.rootDir = normalizePath(dirname(configPath));
unknownConfig.config.rootDir =
typeof config.rootDir === 'string' ? config.rootDir : normalizePath(dirname(configPath));
} else {
// no stencil.config.ts or .js file, which is fine
unknownConfig.config = { ...config };
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/config/test/load-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('load config', () => {
sys,
config: {
hashedFileNameLength: 9,
rootDir: '/foo/bar',
},
initTsConfig: true,
});
Expand All @@ -50,6 +51,8 @@ describe('load config', () => {
expect<ConfigFlags>(actualConfig.flags).toEqual({ dev: true });
expect(actualConfig.extras).toBeDefined();
expect(actualConfig.extras!.enableImportInjection).toBe(true);
// respects custom root dir
expect(actualConfig.rootDir).toBe('/foo/bar');
});

it('uses the provided config path when no initial config provided', async () => {
Expand Down

0 comments on commit b6b9617

Please sign in to comment.