@@ -504,44 +504,21 @@ protected static function pathExists($packageName,$path) {
504
504
*/
505
505
public static function postInstallCmd ($ installerInfo , $ event ) {
506
506
507
- self ::runTasks ($ installerInfo );
507
+ self ::packagesInstall ($ installerInfo );
508
508
509
509
}
510
510
511
511
/**
512
- * Run the PL tasks when Composer runs an update command
512
+ * Run the PL tasks when Composer runs an update command. this also runs after a package is removed.
513
513
* @param {Array} collected package info
514
514
* @param {Object} a script event object from composer
515
515
*/
516
516
public static function postUpdateCmd ($ installerInfo , $ event ) {
517
517
518
- self ::runTasks ($ installerInfo );
519
-
520
- }
521
-
522
- /**
523
- * Make sure pattern engines and listeners are removed on uninstall
524
- * @param {String} the name of the package to be removed
525
- * @param {String} the type of the package to be removed
526
- * @param {String} the path of the package to be removed
527
- */
528
- public static function prePackageUninstallCmd ($ name , $ type , $ pathBase ) {
529
-
530
- // run the console and config inits
531
- self ::init ();
532
-
533
- // see if the package has a listener and remove it
534
- self ::scanForListener ($ pathBase ,true );
535
-
536
- // see if the package is a pattern engine and remove the rule
537
- if ($ type == "patternlab-patternengine " ) {
538
- self ::scanForPatternEngineRule ($ pathBase ,true );
539
- }
540
-
541
- // remove the component package file if it exists
542
- $ jsonFile = Config::getOption ("componentDir " )."/packages/ " .str_replace ("/ " ,"- " ,$ name ).".json " ;
543
- if (file_exists ($ jsonFile )) {
544
- unlink ($ jsonFile );
518
+ if ($ installerInfo ["packagesRemove " ]) {
519
+ self ::packagesRemove ($ installerInfo );
520
+ } else {
521
+ self ::packagesInstall ($ installerInfo );
545
522
}
546
523
547
524
}
@@ -599,7 +576,7 @@ protected static function removeDots($path) {
599
576
* Handle some Pattern Lab specific tasks based on what's found in the package's composer.json file
600
577
* @param {Array} the info culled from installing various pattern lab-related packages
601
578
*/
602
- protected static function runTasks ($ installerInfo ) {
579
+ protected static function packagesInstall ($ installerInfo ) {
603
580
604
581
// initialize a bunch of stuff like config and console
605
582
self ::init ();
@@ -659,6 +636,39 @@ protected static function runTasks($installerInfo) {
659
636
660
637
}
661
638
639
+ /**
640
+ * Make sure pattern engines and listeners are removed on uninstall
641
+ * @param {String} the name of the package to be removed
642
+ * @param {String} the type of the package to be removed
643
+ * @param {String} the path of the package to be removed
644
+ */
645
+ public static function packagesRemove ($ name , $ type , $ pathBase ) {
646
+
647
+ // run the console and config inits
648
+ self ::init ();
649
+
650
+ $ packages = $ installerInfo ["packages " ];
651
+
652
+ foreach ($ packages as $ package ) {
653
+
654
+ // see if the package has a listener and remove it
655
+ self ::scanForListener ($ pathBase ,true );
656
+
657
+ // see if the package is a pattern engine and remove the rule
658
+ if ($ type == "patternlab-patternengine " ) {
659
+ self ::scanForPatternEngineRule ($ pathBase ,true );
660
+ }
661
+
662
+ // remove the component package file if it exists
663
+ $ jsonFile = Config::getOption ("componentDir " )."/packages/ " .str_replace ("/ " ,"- " ,$ name ).".json " ;
664
+ if (file_exists ($ jsonFile )) {
665
+ unlink ($ jsonFile );
666
+ }
667
+
668
+ }
669
+
670
+ }
671
+
662
672
/**
663
673
* Scan the package for a listener
664
674
* @param {String} the path for the package
0 commit comments