Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use .web-ext-config.js for automatic discovery #2843

Merged
merged 7 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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