-
Notifications
You must be signed in to change notification settings - Fork 2.6k
docs(core): document argv in task execution hook contexts #33322
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
|
@copilot Remove the markdown docs file and add it in the appropriate place in the astro-docs project instead. The docs should cover example usages, such as determining what the original command being ran by the user is, and be located alongside existing docs for the hooks. |
…cle guide Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Done in f764814. Removed the root-level markdown file and added the documentation to
|
|
View your CI Pipeline Execution ↗ for commit f764814
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nx Cloud is proposing a fix for your failed CI:
These changes fix the formatting error by running Prettier on the task-running-lifecycle.mdoc file. The documentation content added in this PR was not formatted before committing, causing the astro-docs:format check to fail. Running npx prettier --write on the file ensures it meets the project's code style standards.
We verified this fix by re-running astro-docs:format.
Suggested Fix changes
diff --git a/astro-docs/src/content/docs/extending-nx/task-running-lifecycle.mdoc b/astro-docs/src/content/docs/extending-nx/task-running-lifecycle.mdoc
index 9a3969b015..b593889cca 100644
--- a/astro-docs/src/content/docs/extending-nx/task-running-lifecycle.mdoc
+++ b/astro-docs/src/content/docs/extending-nx/task-running-lifecycle.mdoc
@@ -169,14 +169,16 @@ function isAffectedCommand(argv) {
}
function getTargetName(argv) {
- const targetIndex = argv.findIndex(arg => arg === '-t' || arg === '--target');
+ const targetIndex = argv.findIndex(
+ (arg) => arg === '-t' || arg === '--target'
+ );
return targetIndex !== -1 ? argv[targetIndex + 1] : undefined;
}
export async function postTasksExecution(options, context) {
const isAffected = isAffectedCommand(context.argv);
const target = getTargetName(context.argv);
-
+
// Send analytics with command context
await sendAnalytics({
executionId: context.id,
@@ -203,7 +205,9 @@ When working with `context.argv`, parse it defensively:
const target = context.argv[2];
// Good - searches for the flag
-const targetIndex = context.argv.findIndex(arg => arg === '-t' || arg === '--target');
+const targetIndex = context.argv.findIndex(
+ (arg) => arg === '-t' || arg === '--target'
+);
const target = targetIndex !== -1 ? context.argv[targetIndex + 1] : undefined;
```
Or Apply changes locally with:
npx nx-cloud apply-locally 9bVB-pd98
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 To learn more about Self Healing CI, please visit nx.dev
The
argvfield was already implemented inPreTasksExecutionContextandPostTasksExecutionContextbut lacked tests and documentation for plugin authors to discover and use it.Changes
Added unit tests (
packages/nx/src/daemon/server/handle-tasks-execution-hooks.spec.ts) validating thatargvflows correctly through hook handlers for different command patterns (direct, affected, run-many)Enhanced existing documentation in
astro-docs/src/content/docs/extending-nx/task-running-lifecycle.mdocwith a new section covering:argvfieldUsage
Fixes https://linear.app/nxdev/issue/NXC-3382/add-contextargv-to-task-execution-hook-contexts
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.