@@ -108,8 +108,10 @@ public function setDownload(bool $download = true): static
108108 */
109109 public function run (bool $ interactive = true , bool $ disable_delay_msg = false ): void
110110 {
111- // resolve input, make dependency graph
112- $ this ->resolvePackages ();
111+ if (empty ($ this ->packages )) {
112+ // resolve input, make dependency graph
113+ $ this ->resolvePackages ();
114+ }
113115
114116 if ($ interactive && !$ disable_delay_msg ) {
115117 // show install or build options in terminal with beautiful output
@@ -148,7 +150,10 @@ public function run(bool $interactive = true, bool $disable_delay_msg = false):
148150 }
149151 $ builder = ApplicationContext::get (PackageBuilder::class);
150152 foreach ($ this ->packages as $ package ) {
151- if ($ this ->isBuildPackage ($ package ) || $ package instanceof LibraryPackage && $ package ->hasStage ('build ' )) {
153+ if (
154+ $ this ->isBuildPackage ($ package ) ||
155+ $ package instanceof LibraryPackage && $ package ->hasStage ('build ' ) && !$ package ->getArtifact ()->shouldUseBinary ()
156+ ) {
152157 if ($ interactive ) {
153158 InteractiveTerm::indicateProgress ('Building package: ' . ConsoleColor::yellow ($ package ->getName ()));
154159 }
@@ -213,6 +218,31 @@ public function isPackageResolved(string $package_name): bool
213218 return isset ($ this ->packages [$ package_name ]);
214219 }
215220
221+ public function isPackageInstalled (Package |string $ package_name ): bool
222+ {
223+ if (empty ($ this ->packages )) {
224+ $ this ->resolvePackages ();
225+ }
226+ if (is_string ($ package_name )) {
227+ $ package = $ this ->getPackage ($ package_name );
228+ if ($ package === null ) {
229+ throw new WrongUsageException ("Package ' {$ package_name }' is not resolved. " );
230+ }
231+ } else {
232+ $ package = $ package_name ;
233+ }
234+
235+ // check if package is built/installed
236+ if ($ this ->isBuildPackage ($ package )) {
237+ return $ package ->isInstalled ();
238+ }
239+ if ($ package instanceof LibraryPackage && $ package ->getArtifact ()->shouldUseBinary ()) {
240+ $ artifact = $ package ->getArtifact ();
241+ return $ artifact ->isBinaryExtracted ();
242+ }
243+ return false ;
244+ }
245+
216246 /**
217247 * Returns the download status of all artifacts for the resolved packages.
218248 *
0 commit comments