Skip to content

Commit

Permalink
feat: add .web-ext-config.js to the auto-discovered config files (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee authored Oct 10, 2023
1 parent 3d1a866 commit a9ec30c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export async function discoverConfigFiles({ getHomeDir = os.homedir } = {}) {
path.join(process.cwd(), 'package.json'),
// Look for a magic config in the current working directory.
path.join(process.cwd(), magicConfigName),
// Look for a magic hidden config (preceded by dot) the current working directory.
path.join(process.cwd(), `.${magicConfigName}`),
];

const configs = await Promise.all(
Expand Down
16 changes: 13 additions & 3 deletions tests/unit/test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ describe('config', () => {
process.chdir(tmpDir.path());
try {
const expectedConfig = path.resolve(
path.join(process.cwd(), 'web-ext-config.js'),
path.join(process.cwd(), '.web-ext-config.js'),
);
await fs.writeFile(expectedConfig, 'module.exports = {}');

Expand Down Expand Up @@ -1054,15 +1054,25 @@ describe('config', () => {
);

const projectConfig = path.resolve(
path.join(process.cwd(), 'web-ext-config.js'),
path.join(process.cwd(), '.web-ext-config.js'),
);
await fs.writeFile(projectConfig, 'module.exports = {}');

const projectConfigUndotted = path.resolve(
path.join(process.cwd(), 'web-ext-config.js'),
);
await fs.writeFile(projectConfigUndotted, 'module.exports = {}');

assert.deepEqual(
await _discoverConfigFiles({
getHomeDir: () => fakeHomeDir,
}),
[globalConfig, packageJSONConfig, projectConfig],
[
globalConfig,
packageJSONConfig,
projectConfigUndotted,
projectConfig,
],
);
} finally {
process.chdir(lastDir);
Expand Down

0 comments on commit a9ec30c

Please sign in to comment.