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

cli: add NODE_RUN_SCRIPT_NAME env to node --run #53032

Merged
merged 1 commit into from
May 19, 2024

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented May 17, 2024

Adds the NODE_RUN_SCRIPT_NAME to share name of the event that's run while executing node --run. For example, if the developer runs node --run yagiz, NODE_RUN_SCRIPT_NAME will be yagiz

This PR also includes a small refactor. I moved setting environment variables into SetEnvironmentVariables private function to improve readability.

Ref: #52673

cc @nodejs/cpp-reviewers

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 17, 2024
@anonrig anonrig added the semver-minor PRs that contain new features and should be released in the next minor version. label May 17, 2024
@anonrig anonrig force-pushed the add-node-lifecycle-event branch 2 times, most recently from d1dbd64 to f26e6dd Compare May 17, 2024 02:14
@anonrig anonrig added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels May 17, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 17, 2024
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@targos
Copy link
Member

targos commented May 17, 2024

I don't understand the name. What's the connection between running a script and the concept of a "lifecycle event"?

@anonrig
Copy link
Member Author

anonrig commented May 17, 2024

I don't understand the name. What's the connection between running a script and the concept of a "lifecycle event"?

I don't understand it either. It's named after "npm_lifecycle_event" environment variable that is required for CLI runners to detect which task is being run. The reference issue in PR description might give you more context.

@tniessen
Copy link
Member

Lifecycle events make sense in the context of a package manager, but since this feature apparently doesn't aim for compatibility with any existing package manager or runtime, I think it'd be acceptable to deviate from existing naming conventions.

@anonrig
Copy link
Member Author

anonrig commented May 17, 2024

Lifecycle events make sense in the context of a package manager, but since this feature apparently doesn't aim for compatibility with any existing package manager or runtime, I think it'd be acceptable to deviate from existing naming conventions.

That seems valid to me. @tniessen. Any naming suggestions?

@legendecas
Copy link
Member

An environ named as something like NODE_RUN_COMMAND_NAME would make more sense to me.

@anonrig anonrig changed the title cli: add lifecycle event env to node --run cli: add NODE_RUN_COMMAND_NAME env to node --run May 17, 2024
@legendecas
Copy link
Member

legendecas commented May 17, 2024

Sorry about the churn. Do we have a consensus on "command" vs "script"? I found both in the doc and codebase, but node --run parses the package.json#scripts and runs a script.

@tniessen
Copy link
Member

I'm not necessarily in favor of any of this, but script sounds better than command to me.

@anonrig anonrig changed the title cli: add NODE_RUN_COMMAND_NAME env to node --run cli: add NODE_RUN_SCRIPT_NAME env to node --run May 17, 2024
@nodejs-github-bot
Copy link
Collaborator

@benjamingr
Copy link
Member

(the ask and solution seem reasonable to me)

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label May 18, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 19, 2024
@nodejs-github-bot nodejs-github-bot merged commit cb90a31 into nodejs:main May 19, 2024
53 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in cb90a31

targos pushed a commit that referenced this pull request May 21, 2024
PR-URL: #53032
Refs: #52673
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
lukins-cz pushed a commit to lukins-cz/OS-Aplet-node that referenced this pull request Jun 1, 2024
PR-URL: nodejs#53032
Refs: nodejs#52673
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants