From 9eee719c7bf011b63d620bfeac02d678cdaa7aae Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Sat, 10 Oct 2020 14:51:03 +0530 Subject: [PATCH] refactor: use arrow functions --- packages/webpack-cli/lib/bootstrap.js | 8 +++----- packages/webpack-cli/lib/utils/arg-parser.js | 4 ++-- packages/webpack-cli/lib/utils/cli-executer.js | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/webpack-cli/lib/bootstrap.js b/packages/webpack-cli/lib/bootstrap.js index cfd6e415940..5428c5dd74b 100644 --- a/packages/webpack-cli/lib/bootstrap.js +++ b/packages/webpack-cli/lib/bootstrap.js @@ -13,11 +13,9 @@ process.title = 'webpack-cli'; // Create a new instance of the CLI object const cli = new WebpackCLI(); -function parseArgs(args) { - return argParser(core, args, true, process.title); -} +const parseArgs = (args) => argParser(core, args, true, process.title); -async function runCLI(cliArgs) { +const runCLI = async (cliArgs) => { let args; const commandIsUsed = isCommandUsed(cliArgs); @@ -108,6 +106,6 @@ async function runCLI(cliArgs) { return; } } -} +}; module.exports = runCLI; diff --git a/packages/webpack-cli/lib/utils/arg-parser.js b/packages/webpack-cli/lib/utils/arg-parser.js index ef379d735cc..c72ad1bd7d4 100644 --- a/packages/webpack-cli/lib/utils/arg-parser.js +++ b/packages/webpack-cli/lib/utils/arg-parser.js @@ -13,7 +13,7 @@ const { defaultCommands } = require('./commands'); * @param {boolean} argsOnly false if all of process.argv has been provided, true if * args is only a subset of process.argv that removes the first couple elements */ -function argParser(options, args, argsOnly = false, name = '') { +const argParser = (options, args, argsOnly = false, name = '') => { const parser = new commander.Command(); // Set parser name parser.name(name); @@ -155,6 +155,6 @@ function argParser(options, args, argsOnly = false, name = '') { unknownArgs, opts, }; -} +}; module.exports = argParser; diff --git a/packages/webpack-cli/lib/utils/cli-executer.js b/packages/webpack-cli/lib/utils/cli-executer.js index b51ee3f92be..7a699986536 100644 --- a/packages/webpack-cli/lib/utils/cli-executer.js +++ b/packages/webpack-cli/lib/utils/cli-executer.js @@ -3,7 +3,7 @@ const { cyan } = require('colorette'); const logger = require('./logger'); const cliArgs = require('./cli-flags').core; -async function prompter() { +const prompter = async () => { const args = []; const typePrompt = new MultiSelect({ @@ -48,9 +48,9 @@ async function prompter() { } return [...args, ...boolArgs]; -} +}; -async function run() { +const run = async () => { try { const args = await prompter(); logger.info('\nExecuting CLI\n'); @@ -59,6 +59,6 @@ async function run() { logger.error(`${err} Action Interrupted, use ${cyan('webpack-cli help')} to see possible options.`); process.exit(1); } -} +}; module.exports = run;