Skip to content

Commit

Permalink
fix: duplicate entry issue
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jun 20, 2020
1 parent f12efe4 commit 6c52f32
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-cli/lib/utils/arg-parser.js
Expand Up @@ -93,7 +93,7 @@ function argParser(options, args, argsOnly = false, name = '', helpFunction = un
delete opts[key];
}
});

return {
unknownArgs,
opts,
Expand Down
15 changes: 14 additions & 1 deletion packages/webpack-cli/lib/utils/cli-flags.js
Expand Up @@ -10,7 +10,7 @@ const ZERO_CONFIG_GROUP = 'zero-config';

// Extract all the flages being exported from core. A list of cli flags generated by core
// can be found here https://github.com/webpack/webpack/blob/master/test/__snapshots__/Cli.test.js.snap
const flagsFromCore = version.startsWith(5)
let flagsFromCore = version.startsWith(5)
? Object.entries(require('webpack').cli.getArguments()).map(([flag, meta]) => {
if (meta.simpleType === 'string') {
meta.type = String;
Expand All @@ -30,6 +30,9 @@ const flagsFromCore = version.startsWith(5)
})
: [];

// remove entry flag to avoid duplicate entry
flagsFromCore = flagsFromCore.filter((flag) => flag.name !== 'entry');

module.exports = {
groups: {
HELP_GROUP,
Expand Down Expand Up @@ -94,6 +97,16 @@ module.exports = {
},
],
core: [
{
name: 'entry',
usage: '--entry <path to entry file> | --entry <path> --entry <path>',
type: String,
multiple: true,
defaultOption: true,
group: BASIC_GROUP,
description: 'The entry point(s) of your application e.g. ./src/main.js',
link: 'https://webpack.js.org/concepts/#entry',
},
{
name: 'config',
usage: '--config <path to webpack configuration file>',
Expand Down
22 changes: 0 additions & 22 deletions test/core-flags/core-flags.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/core-flags/experiments-flag.test.js
Expand Up @@ -3,7 +3,7 @@
const { run, hyphenToUpperCase } = require('../utils/test-utils');
const { flagsFromCore } = require('../../packages/webpack-cli/lib/utils/cli-flags');

const experimentsFlags = flagsFromCore.filter((flag) => flag.name.includes('experiments-'));
const experimentsFlags = flagsFromCore.filter(({ name }) => name.startsWith('experiments-'));

describe('experiments option related flag', () => {
experimentsFlags.forEach((flag) => {
Expand Down

0 comments on commit 6c52f32

Please sign in to comment.