/**
  * move
  *
  * @param string  $src
  * @param string  $dest
  * @param bool    $force
  *
  * @return  bool
  */
 public static function move($src, $dest, $force = false)
 {
     if (is_dir($src)) {
         Folder::move($src, $dest, $force);
     } elseif (is_file($src)) {
         File::move($src, $dest, $force);
     }
     return true;
 }
 /**
  * Method to test move().
  *
  * @return void
  *
  * @covers Windwalker\Filesystem\Folder::move
  */
 public function testMove()
 {
     $dest2 = __DIR__ . '/dest2';
     if (is_dir($dest2)) {
         Folder::delete($dest2);
     }
     Folder::move(static::$dest, $dest2);
     $this->assertTrue(is_dir($dest2));
     $this->assertFileExists($dest2 . '/folder1/level2/file3');
     Folder::delete($dest2);
 }
Beispiel #3
0
    // Prepare dist folder
    if (file_exists($distfolder)) {
        Filesystem::delete($distfolder);
        Folder::create($distfolder);
    }
    $task->writeln('Copying files over.');
    recursiveCopy('dev', $basepath, $distfolder);
    $task->writeln('Running composer');
    $task->exec(function ($process) {
        $basepath = realpath(__DIR__ . '/..');
        $distfolder = Path::clean($basepath . '/dist');
        $distfolder = str_replace(' ', '\\ ', $distfolder);
        $process->runLocally("cd " . $distfolder . '/dev' . " && composer install --prefer-dist --optimize-autoloader");
        $process->runLocally("cd .. && cd ..");
    });
    Folder::move($distfolder . '/dev', $distfolder . '/notify');
    $task->writeln('Zipping');
    $zippy = Zippy::load();
    $archive = $zippy->create('flarum-notify.zip', array('notify' => $distfolder . '/notify'));
    $task->writeln('Deleting copied folder');
    Folder::delete($distfolder . '/notify');
    File::move($basepath . '/flarum-notify.zip', $distfolder . '/flarum-notify.zip');
})->description("Builds a release ready package from the current project state and stores it in /dist.");
function recursiveCopy($filename, $initialfolder, $targetfolder)
{
    $badfiles = ['vendor', 'node_modules', '.DS_Store', 'sftp-config.json', '.git', '.gitignore', 'build.sh'];
    foreach (Folder::items($initialfolder . '/' . $filename, false, Folder::PATH_BASENAME) as $item) {
        if (!in_array($item, $badfiles)) {
            if (is_dir($initialfolder . '/' . $filename . '/' . $item)) {
                recursiveCopy($item, $initialfolder . '/' . $filename, $targetfolder . '/' . $filename);
            } else {