Skip to content

Conversation

@FrozenPandaz
Copy link
Collaborator

@FrozenPandaz FrozenPandaz commented Jan 15, 2025

Current Behavior

There is no specific API for running things before and after tasks run.

Expected Behavior

This PR adds an API akin to npm's preinstall and postinstall.

Plugins can now specify preTasksExecution and postTasksExecution functions which run before and after Nx runs tasks respectively.

import type { PreTasksExecutionContext, PostTasksExecutionContext } from '@nx/devkit';

interface PluginOptions {
  field: any;
}

export function preTasksExecution(options: PluginOptions, context: PreTasksExecutionContext) {
  console.log('prerun')
}

export function postTasksExecution(options: PluginOptions, context: PostTasksExecutionContext) {
  console.log('postrun', context.taskResults)
}

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jan 27, 2025 4:30pm

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Jan 15, 2025

View your CI Pipeline Execution ↗ for commit 0159794.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 35m 4s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 1m 4s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx format:check --base=a8aba... ✅ Succeeded 26s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 24s View ↗
nx documentation --no-dte ✅ Succeeded 1m 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-27 17:10:27 UTC

@github-actions
Copy link
Contributor

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx [email protected] my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-29636-e3c31b7
Release details 📑
Published version 0.0.0-pr-29636-e3c31b7
Triggered by @FrozenPandaz
Branch lifecycles
Commit e3c31b7
Workflow run 12798193611

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@github-actions
Copy link
Contributor

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx [email protected] my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-29636-0cd26ed
Release details 📑
Published version 0.0.0-pr-29636-0cd26ed
Triggered by @FrozenPandaz
Branch lifecycles
Commit 0cd26ed
Workflow run 12877113856

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@FrozenPandaz FrozenPandaz merged commit 4a9508b into master Jan 27, 2025
6 checks passed
@FrozenPandaz FrozenPandaz deleted the lifecycles branch January 27, 2025 17:09
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2025

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants