From 83c15590d3859f7515b79137f4c4aeae0c2c27e3 Mon Sep 17 00:00:00 2001 From: Bucky Maler Date: Fri, 5 Jul 2019 20:16:32 -0500 Subject: [PATCH] fix(nx): make target a required option when running affected npm script --- docs/api-workspace/npmscripts/affected.md | 4 ++++ packages/workspace/src/command-line/nx-commands.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/api-workspace/npmscripts/affected.md b/docs/api-workspace/npmscripts/affected.md index 1ccd8eafcb6fc..e21e2cffae1a4 100644 --- a/docs/api-workspace/npmscripts/affected.md +++ b/docs/api-workspace/npmscripts/affected.md @@ -56,6 +56,10 @@ Parallelize the command ### quiet +### target + +Task to run for affected projects + ### uncommitted Uncommitted changes diff --git a/packages/workspace/src/command-line/nx-commands.ts b/packages/workspace/src/command-line/nx-commands.ts index 7baf0ed27cd98..c8ef8177a285a 100644 --- a/packages/workspace/src/command-line/nx-commands.ts +++ b/packages/workspace/src/command-line/nx-commands.ts @@ -22,7 +22,7 @@ export const commandsObject = yargs .command( 'affected', 'Run task for affected projects', - yargs => withAffectedOptions(withParallel(yargs)), + yargs => withAffectedOptions(withParallel(withTarget(yargs))), args => affected(args) ) .command( @@ -247,3 +247,13 @@ function withParallel(yargs: yargs.Argv): yargs.Argv { default: 3 }); } + +function withTarget(yargs: yargs.Argv): yargs.Argv { + return yargs.option('target', { + describe: 'Task to run for affected projects', + type: 'string', + requiresArg: true, + demandOption: true, + global: false + }); +}