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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

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

wants to merge 2 commits into from

Conversation

FrozenPandaz
Copy link
Collaborator

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 preRun and postRun functions which run before and after Nx runs tasks respectively.

import type { PreRunContext, PostRunContext } from '@nx/devkit';

interface PluginOptions {
  field: any;
}

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

export function postRun(options: PluginOptions, context: PostRunContext) {
  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 15, 2025 10:27pm

Copy link

nx-cloud bot commented Jan 15, 2025

View your CI Pipeline Execution ↗ for commit e3c31b7.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 37m 5s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 1m 4s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=7ef4f... ✅ Succeeded 27s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 25s View ↗
nx documentation --no-dte ✅ Succeeded 1m 12s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-15 23:08:36 UTC

@nrwl nrwl deleted a comment from github-actions bot Jan 15, 2025
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.

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.

1 participant