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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

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

wants to merge 4 commits into from

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 26, 2025 4:53am

Copy link

nx-cloud bot commented Jan 15, 2025

View your CI Pipeline Execution ↗ for commit c29c361.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 40m 37s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 54s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx format:check --base=1c8b3... ✅ Succeeded 16s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 14s View ↗
nx documentation --no-dte ✅ Succeeded 59s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-26 05:37:22 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.

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