Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add pre and post run apis #29636

Merged
merged 3 commits into from
Jan 27, 2025
Merged

feat(core): add pre and post run apis #29636

merged 3 commits into from
Jan 27, 2025

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 #

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

Copy link

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

Copy link

🐳 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.

Copy link

🐳 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants