is their Support for running scripts after certain events happen. like npm provides https://docs.npmjs.com/misc/scripts. if no is this under development or under discussion?
Hi Aniket,
We don't have that sort of support today. There are a couple different kinds of scripting hooks one might want. The one I've expected people to want more are hooks to run custom commands / scripts during a package build, e.g. to support a build tool that SwiftPM doesn't know about. This is important to broaden the range of what we can build, but also needs to be approached with caution, as it can prevent SwiftPM from fully understanding what happens during the build. This is something we should solve at some point, but it hasn't been at the top of anyone's to-do list.
That said, it sounds like you're more talking about scripting hooks around higher level package manager actions, not scripts that run during a build. I don't think anyone's requested that so far. I expect it's sometimes easy for people to write scripts that do what they want and invoke SwiftPM at the right time, rather than making SwiftPM invoke their scripts. That said, this does seem desirable, so a real proposal would be worth discussing!
Thanks @rballard,
Sure, I will work on this one, I never wrote swift evolution proposal before, I am new here, I found this Resource is there anything more I should know before writing one? it may take me awhile to do so ( having my exams till 28th)
This has been an idea circulating my head for a while as well. Though only to the extend of npm's postinstall
and preinstall
scripts. Would love the ability to define post-
and pre-
commands for clean
, update
and resolve
in my Package.swift! :)
I kind of ended up exploring something like that here. It’s a bit of a lateral solution, and only the bare bones at that, but I might hack on it a little more if anyone is interested.
The prototype is a standalone tool but obviously a real implementation could be integrated into spm itself.