/** * 初始化匯入資料. * * @return void */ protected function init() { $dir = $this->option('dir') ? realpath($this->option('dir')) : false; if (false !== $dir && $this->filesystem->isDirectory($dir)) { $this->files = array_merge($this->files, $this->filesystem->glob(file_build_path($dir, '*.html'))); } $file = $this->option('file') ? realpath($this->option('file')) : false; if (false !== $file && ends_with($file, '.html') && $this->filesystem->isFile($file)) { $this->files[] = $file; } }
/** * 判斷是否要重新啟動 queue. * * @return bool */ protected function queueNeedRestart() { switch (true) { case $this->isModified(app_path(file_build_path('Console', 'Commands', 'Deploy.php'))): case $this->isModified(base_path('composer.lock')): $this->call('queue:restart'); Artisan::queue('deploy', ['--isRestart' => true]); return true; default: return false; } }
/** * Decompress archive and delete non-used files. * * @return void */ protected function decompress() { $directory = dirname($this->archivePath); $this->externalCommand("tar zxf {$this->archivePath}", $directory); $specifics = [file_build_path($directory, 'index.html'), file_build_path($directory, 'all_english.html'), $this->archivePath]; $this->filesystem->delete(array_merge($this->filesystem->glob(file_build_path($directory, '*e.html')), $this->getOldFiles($directory), $specifics)); }