Skip to content

Commit

Permalink
tests: lookup test
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed Oct 27, 2019
1 parent d7799ad commit 6686f8b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4,314 deletions.
18 changes: 11 additions & 7 deletions lib/groups/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { existsSync } = require('fs');
const { resolve, extname } = require('path');
const { resolve, extname, sep } = require('path');

const GroupHelper = require('../utils/group-helper');

Expand Down Expand Up @@ -48,7 +48,6 @@ class ConfigGroup extends GroupHelper {

requireConfig(configPath) {
const { register } = this.args;

return (() => {
if (register && register.length) {
module.paths.unshift(resolve(process.cwd(), 'node_modules'));
Expand Down Expand Up @@ -93,20 +92,25 @@ class ConfigGroup extends GroupHelper {
}
}
}

let configOptions = [];
if (configFiles) {
// TODO: support mjs etc..
const resolvedConfigurationFiles = this.requireConfig(configFiles.path);
configOptions = resolvedConfigurationFiles;
if (configOptions && configFiles.path.includes('.webpack')) {
const currentPath = configFiles.path;
const parentContext = path.dirname(currentPath).split(sep).slice(0, -1).join('/');
configOptions.context = configOptions.context || parentContext;
}
}
if (configOptions.length > 0) {
this.opts['options'] = configOptions;
}
}
else if (typeof configOptions === 'function') {
const newOptions = await configOptions();
this.opts['options'] = newOptions;
}
}
else {
if (Array.isArray(configOptions) && !configOptions.length) {
this.opts['options'] = {};
Expand All @@ -118,11 +122,11 @@ class ConfigGroup extends GroupHelper {

resolveConfigMerging() {
if (this.args.hasOwnProperty('merge')) {
const {merge} = this.args;
const { merge } = this.args;

const newConfigPath = this.resolveFilePath(merge, 'webpack.base.js');
const newConfig = newConfigPath ? this.require(newConfigPath) : null;

const webpackMerge = require('webpack-merge');
this.opts['options'] = webpackMerge(this.opts['options'], newConfig);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ function generateOutput(outputOptions, stats, statsErrors) {
}
generateOutputForSingleCompilation(statsObj, statsErrors);
process.stdout.write('\n');
process.cliLogger.info('watching files for updates...');
if (outputOptions.watch) {
process.cliLogger.info('watching files for updates...');
}
}

function generateOutputForSingleCompilation(statsObj, statsErrors) {
Expand Down

0 comments on commit 6686f8b

Please sign in to comment.