Skip to content

Commit

Permalink
fix: remove fallback to base config
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Jul 18, 2020
1 parent 09932a1 commit 63e9e22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/webpack-cli/lib/groups/ConfigGroup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { existsSync } = require('fs');
const { resolve, sep, dirname, parse } = require('path');
const { extensions } = require('interpret');
const webpackMerge = require('webpack-merge');
const GroupHelper = require('../utils/GroupHelper');
const rechoir = require('rechoir');
const logger = require('../utils/logger');
Expand Down Expand Up @@ -173,7 +174,8 @@ class ConfigGroup extends GroupHelper {
const newConfigPath = this.resolveFilePath(merge);

if (!newConfigPath) {
return logger.warn("The supplied merge config doesn't exist.");
logger.error("The supplied merge config doesn't exist.");
process.exit(1);
}

const configFiles = getConfigInfoFromFileName(newConfigPath);
Expand All @@ -187,7 +189,6 @@ class ConfigGroup extends GroupHelper {
const foundConfig = configFiles[0];
const resolvedConfig = this.requireConfig(foundConfig);
const newConfigurationsObject = await this.finalize(resolvedConfig);
const webpackMerge = require('webpack-merge');
this.opts['options'] = webpackMerge(this.opts['options'], newConfigurationsObject.options);
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/merge/config-absent/merge-config-absent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ describe('merge flag configuration', () => {
// 2.js doesn't exist, let's try merging with it
const { stdout, stderr } = run(__dirname, ['--config', './1.js', '--merge', './2.js'], false);

expect(stdout).toBeTruthy();
// Since the process will exit, nothing on stdout
expect(stdout).toBeFalsy();
// Confirm that the user is notified
expect(stderr).toContain(`[webpack-cli] The supplied merge config doesn't exist.`);
// Default config would be used
expect(fs.existsSync(join(__dirname, './dist/merged.js'))).toBeFalsy();
expect(fs.existsSync(join(__dirname, './dist/main.js'))).toBeTruthy();
// Since the process will exit so no compilation will be done
expect(fs.existsSync(join(__dirname, './dist/main.js'))).toBeFalsy();
});
});

0 comments on commit 63e9e22

Please sign in to comment.