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: add preinstallOnly script #6888

Closed
wants to merge 1 commit into from
Closed

feat: add preinstallOnly script #6888

wants to merge 1 commit into from

Conversation

hamirmahal
Copy link

No description provided.

@hamirmahal hamirmahal requested a review from a team as a code owner October 9, 2023 11:47
@hamirmahal
Copy link
Author

What / Why

preinstall doesn't actually run before installation. This pull request adds a preinstallOnly script that should run before installation, although I haven't been able to test it with a package.json that has a preinstallOnly script, and I would like to.

@hamirmahal
Copy link
Author

I got the idea to use preinstallOnly from #2660 (comment).

you're not wrong, to be honest a lot of our lifecycle scripts are poorly named and don't run exactly when you expect. that's why there's both a prepublish and a prepublishOnly. we have a lot of technical debt here, but changing the expectations about how lifecycle scripts work is a glacier of a breaking change.

the best we can do right now is clearly document when scripts run and what's available to them

@wraithgar
Copy link
Member

This would constitute a breaking change and would have to wait till npm 11

@ljharb
Copy link
Contributor

ljharb commented Oct 9, 2023

Why would a new script be a breaking change?

@wraithgar
Copy link
Member

Ah my oversight, I thought this was moving an existing script

@hamirmahal
Copy link
Author

I was able to test it out locally just now, and it appears to work as intended.

@hamirmahal
Copy link
Author

package.json.-.cli.WSL_.Ubuntu.-.Visual.Studio.Code.2023-10-10.16-23-47.mp4

@MattCCC
Copy link

MattCCC commented Oct 11, 2023

Works well on mine.

@nkamenar
Copy link

Any word on when this will release? My team is switching to pnpm also and running into exactly this problem where someone accidentally runs npm install and we can't prevent it.

@hamirmahal
Copy link
Author

@wraithgar what changes would you like this pull request to have, to consider merging it?

@wraithgar
Copy link
Member

This is a great contribution and it seems to fit into a point of the install lifecycle that might not be fully covered yet. Our team is currently reviewing the npm lifecycle hooks as a whole and the best resolutions for it moving forward.

Unfortunately this means we won't be able to accept this new feature knowing it may eventually be affected by a breaking change.

@wraithgar wraithgar closed this Mar 19, 2024
@hamirmahal hamirmahal deleted the feat/npm-preinstallOnly-script branch March 19, 2024 20:34
@hamirmahal
Copy link
Author

Okay, thanks for the explanation.

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.

5 participants