Skip to content

Commit

Permalink
refactor: cliExecuter consumes runCLI (#1754)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Aug 19, 2020
1 parent d3e2936 commit 08aaff3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
10 changes: 5 additions & 5 deletions packages/webpack-cli/__tests__/cli-executer.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
jest.mock('../lib/runner');
jest.mock('../lib/bootstrap');
jest.mock('enquirer');

const runner = require('../lib/runner');
runner.mockImplementation(() => {});
const runCLI = require('../lib/bootstrap');
runCLI.mockImplementation(() => {});

describe('CLI Executer', () => {
let cliExecuter = null;
Expand Down Expand Up @@ -48,8 +48,8 @@ describe('CLI Executer', () => {
await cliExecuter();

// ensure that the webpack runCLI is called
expect(runner.mock.calls.length).toEqual(1);
expect(runner.mock.calls[0]).toEqual([[], ['--config', 'test1', '--entry', 'test2', '--progress']]);
expect(runCLI.mock.calls.length).toEqual(1);
expect(runCLI.mock.calls[0][0]).toEqual(['--config', 'test1', '--entry', 'test2', '--progress']);

// check that webpack options are actually being displayed that
// the user can select from
Expand Down
10 changes: 0 additions & 10 deletions packages/webpack-cli/lib/runner.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/webpack-cli/lib/utils/cli-executer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { MultiSelect, Input } = require('enquirer');
const { cyan } = require('colorette');
const logger = require('./logger');
const cliArgs = require('./cli-flags').core;
const runner = require('../runner');
const runCLI = require('../bootstrap');

async function prompter() {
const args = [];
Expand Down Expand Up @@ -56,7 +56,7 @@ async function run() {
const args = await prompter();
process.stdout.write('\n');
logger.info('Executing CLI\n');
await runner([], args);
await runCLI(args);
} catch (err) {
logger.error(`Action Interrupted, use ${cyan('webpack-cli help')} to see possible options.`);
}
Expand Down

0 comments on commit 08aaff3

Please sign in to comment.