Example #1
0
 /**
  * @param ComposerSymLog $log
  */
 public static function run(ComposerSymLog $log)
 {
     foreach ($log->getLinkedPackages() as $linkedPackage) {
         $doUnlink = UserPrompt::confirm(sprintf("\n> Would you like to unlink %s?", $linkedPackage->package), 'n');
         if ($doUnlink) {
             rmdir($linkedPackage->location);
             rename($linkedPackage->tempLocation, $linkedPackage->location);
             // Sometimes rename leaves a copy of both directories, we double check
             // that it's actually gone here and if not remove it.
             if (file_exists($linkedPackage->tempLocation)) {
                 rmdir($linkedPackage->tempLocation);
             }
             printf("> %s unlinked\n", $linkedPackage->package);
             $log->removePackage($linkedPackage->package);
         }
     }
 }
Example #2
0
 /**
  * @param ComposerSymLog  $log
  * @param ComposerSym     $composerSym
  * @param ComposerSymCore $core
  * @param string          $package
  *
  * @throws \Garoevans\ComposerSym\Exception\ComposerSymException
  */
 private static function runSymLink(ComposerSymLog $log, ComposerSym $composerSym, ComposerSymCore $core, $package)
 {
     $potentialLocation = $core->getPotentialLinkLocation($package, $composerSym->homeDir);
     if (strlen($potentialLocation) === 0) {
         $linkTo = $core->getLinkLocation($package);
     } else {
         $linkTo = $potentialLocation;
     }
     // Move the existing package to a new temporary directory and symlink
     // to the local copy
     $tempLocation = build_path($composerSym->projectDir, $composerSym->vendor, $core->getTemporaryPackageName($package));
     $packageLocation = self::getPackageLocation($composerSym, $package);
     rename($packageLocation, $tempLocation);
     if (!symlink($linkTo, $packageLocation)) {
         rename($tempLocation, $packageLocation);
         throw new ComposerSymException("Failed creating sym link, this could be a privileges issue. Try" . "running the console with raised privileges.");
     }
     printf("> %s symlinked:\n", $package);
     printf(">> link: %s\n", $packageLocation);
     printf(">> target: %s\n", $linkTo);
     $log->addPackage($package, $packageLocation, $tempLocation);
     unset($linkTo);
     echo "\n";
 }