コード例 #1
0
 /**
  * Run any migrations found in core/migrations that match the approved types
  * @param  {String}      the filename of the migration
  * @param  {String}      the path of the source directory
  * @param  {String}      the path to the destination
  * @param  {Boolean}     moving a single file or a directory
  */
 protected function runMigration($filename, $sourcePath, $destinationPath, $singleFile)
 {
     $filename = str_replace(".json", "", $filename);
     print "starting the " . $filename . " migration...\n";
     if ($singleFile) {
         copy($sourcePath . $fileName, $destinationPath . $fileName);
     } else {
         if (strpos($sourcePath, "pattern-lab/") !== false) {
             $sourcePath = str_replace(__DIR__ . "/../../../", "", rtrim($sourcePath, "/"));
             $f = new Fetch();
             $f->fetch("starterkit", $sourcePath);
         } else {
             $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourcePath), \RecursiveIteratorIterator::SELF_FIRST);
             $objects->setFlags(\FilesystemIterator::SKIP_DOTS);
             foreach ($objects as $object) {
                 // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
                 $fileName = str_replace($sourcePath, "", $object->getPathname());
                 // check to see if it's a new directory
                 if ($object->isDir() && !is_dir($destinationPath . $fileName)) {
                     mkdir($destinationPath . $fileName);
                 } else {
                     if ($object->isFile()) {
                         copy($sourcePath . $fileName, $destinationPath . $fileName);
                     }
                 }
             }
         }
     }
     print "completed the " . $filename . " migration...\n";
 }