You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't a high-priority issue, or even an issue at all, but a suggestion for feature that I feel would be helpful.
The idea: Just like how NPM supports scripts, i.e. postinstall, prepublish, it would be nice if Pub did as well. This would make it possible to do things such as compiling native extensions after installing them from Pub.
Pubspec Change
IMO, it would be best to just include scripts in the pubspec.yaml file:
name: my_packagescripts:
greet: echo Hello Worldinstall:
- echo This is a postinstall script!!!
- pub run-script greet
Command
Pub already has a run command, so it might make more sense to support scripts via something like run-script.
Supported Scripts
I think that Pub would only need to support about three scenarios:
install - Runs after a new version of the current package is installed, whether after the initial pub get, or a pub upgrade. Since Pub packages are cached, users wouldn't have to re-run the scripts each time they used a cache version of the package.
get - Runs after pub get. This script will only be run when developing the package; not if it is downloaded from Pub or another source.
upgrade - Same as get, except for that it would run after pub upgrade. Personally, I don't think it would even be necessary.
How it Works
In my head, the process would be something like the following:
User runs pub get.
For each package with an install script, the script is run. It might make sense to show the user the commands that will run, and allow them to opt out.
If the local package has a get script, it is run as well. There probably won't need to be an opt-out feature here.
It might also be a good idea to include a flag to automatically run all scripts, i.e. --run-all-scripts.
Anyways, hopefully this is considered. I'm more than willing to send in a PR.
The text was updated successfully, but these errors were encountered:
This isn't a high-priority issue, or even an issue at all, but a suggestion for feature that I feel would be helpful.
The idea: Just like how NPM supports scripts, i.e.
postinstall
,prepublish
, it would be nice if Pub did as well. This would make it possible to do things such as compiling native extensions after installing them from Pub.Pubspec Change
IMO, it would be best to just include scripts in the
pubspec.yaml
file:Command
Pub already has a
run
command, so it might make more sense to support scripts via something likerun-script
.Supported Scripts
I think that Pub would only need to support about three scenarios:
install
- Runs after a new version of the current package is installed, whether after the initialpub get
, or apub upgrade
. Since Pub packages are cached, users wouldn't have to re-run the scripts each time they used a cache version of the package.get
- Runs afterpub get
. This script will only be run when developing the package; not if it is downloaded from Pub or another source.upgrade
- Same asget
, except for that it would run afterpub upgrade
. Personally, I don't think it would even be necessary.How it Works
In my head, the process would be something like the following:
pub get
.install
script, the script is run. It might make sense to show the user the commands that will run, and allow them to opt out.get
script, it is run as well. There probably won't need to be an opt-out feature here.It might also be a good idea to include a flag to automatically run all scripts, i.e.
--run-all-scripts
.Anyways, hopefully this is considered. I'm more than willing to send in a PR.
The text was updated successfully, but these errors were encountered: