nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.2k stars 28.91k forks source link

Support for running bin scripts using `node --run` #53845

Open manoraj opened 1 month ago

manoraj commented 1 month ago

What is the problem this feature will solve?

This feature will help run the bin scripts in package.json, similar to running scripts. During local development, it's very common to run the bin scripts, and it would be great if the node task runner supported it.

What is the feature you are proposing to solve the problem?

Add node --run --bin or node --run-bin. This will run the bin script similar to what node --run does, except it looks for a bin field.

I know node task runner is not a replacement for something like yarn, but, another option is to support both the fields (scripts and bin) with node --run, similar to what yarn does.

What alternatives have you considered?

No response

KunalKumar-1 commented 1 month ago

It seems like you're proposing a cli feature related to running executable scripts defined in the bin field of package.json files, similar to how npm run executes scripts defined in the scripts field. is it ?

manoraj commented 1 month ago

It seems like you're proposing a cli feature related to running executable scripts defined in the bin field of package.json files, similar to how npm run executes scripts defined in the scripts field. is it ?

@KunalKumar-1 Yes. Node already has node --run. Ask is to extend it to bin scripts as well.

jasnell commented 1 month ago

Since we've added --run supporting bin also seems to make sense. Perhaps node --bin foo would work?

manoraj commented 1 month ago

Since we've added --run supporting bin also seems to make sense. Perhaps node --bin foo would work?

That's one option. The other option is to extend checking both scripts and bin fields in package.json with --run. Just like how yarn <script> does.