Skip to content

Commit

Permalink
projects option
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandi Barr committed Apr 19, 2021
1 parent d9efbf8 commit 28a47e4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions libs/vscode/tasks/src/lib/nx-task-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ const AFFECTED_OPTIONS: Option[] = [
].map((v) => ({ ...v, aliases: [] }));

const RUN_MANY_OPTIONS: Option[] = [
{
name: 'projects',
type: OptionType.Array,
description: 'Projects to run',
},
{ name: 'all', type: OptionType.Boolean, description: 'All projects' },
{
name: 'parallel',
Expand Down Expand Up @@ -266,13 +261,22 @@ async function promptForRunMany() {
return;
}

let options = RUN_MANY_OPTIONS;
const projects = validProjectsForTarget(target);
const projectsOption = RUN_MANY_OPTIONS.find(opt => opt.name === 'projects');
if (projectsOption && projects && projects.length) {
projectsOption.enum = projects;
if (projects && projects.length) {
options = [
{
name: 'projects',
type: OptionType.Array,
description: 'Projects to run',
aliases: [],
enum: projects,
},
...RUN_MANY_OPTIONS,
];
}

const flags = await selectFlags('run-many', RUN_MANY_OPTIONS, 'nx', {target});
const flags = await selectFlags('run-many', options, 'nx', { target });

if (flags !== undefined) {
const task = NxTask.create(
Expand Down Expand Up @@ -340,7 +344,9 @@ function validProjectsForTarget(target: string): string[] | undefined {
return Array.from(
new Set(
Object.entries<ProjectDef>(json.projects)
.filter(([_, project]) => project.architect && project.architect[target])
.filter(
([_, project]) => project.architect && project.architect[target]
)
.map(([project]) => project)
)
).sort();
Expand Down

0 comments on commit 28a47e4

Please sign in to comment.