Skip to content

Commit

Permalink
Add --tasks flag to wpdev CLI bundle command (#104)
Browse files Browse the repository at this point in the history
* Add `--tasks` flag to wpdev CLI bundle command

* Add changeset

* Remove conflicting alias char

* Update bundle.ts
  • Loading branch information
irshadahmad21 authored Feb 19, 2024
1 parent e12a25c commit 32fc287
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-bananas-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wpsocio/wpdev": patch
---

Added `--tasks` flag to wpdev CLI bundle command
1 change: 0 additions & 1 deletion tools/wpdev/src/base-commands/WithConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export abstract class WithConfig extends Command {
'project-types': Flags.option({
description:
'Project types managed in the monorepo. Only used in wp-monorepo mode.',
char: 't',
options: ['plugins', 'themes'] as const,
multiple: true,
})(),
Expand Down
16 changes: 15 additions & 1 deletion tools/wpdev/src/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default class Bundle extends WithProjects<typeof Bundle> {
description: 'Version to update to.',
exclusive: ['release-type'],
}),
tasks: Flags.string({
description: 'Run only the specified tasks. Comma-separated list.',
}),
'release-type': Flags.string({
char: 't',
description: 'Release type to update to.',
Expand Down Expand Up @@ -161,8 +164,19 @@ export default class Bundle extends WithProjects<typeof Bundle> {

const projectDir = project.dir;

const tasksToRun = this.flags.tasks?.split(',') || [];

const taskList = tasksToRun.length
? bundle.tasks.filter((tsk) => tasksToRun.includes(tsk.type))
: bundle.tasks;

if (!taskList.length) {
task.skip('No tasks to run. Skipping.');
return;
}

return task.newListr(
bundle.tasks.map(({ type: taskType, data: taskData }) => {
taskList.map(({ type: taskType, data: taskData }) => {
switch (taskType) {
case 'run-scripts':
return {
Expand Down

0 comments on commit 32fc287

Please sign in to comment.