public function PhoneInternationalCommands::drushTarballExtract in International Phone 3.x
Drush Tarball Extract.
Parameters
string $path: The filename or directory.
bool $destination: The destination path.
Throws
\Exception
1 call to PhoneInternationalCommands::drushTarballExtract()
- PhoneInternationalCommands::plugin in src/
Commands/ PhoneInternationalCommands.php - Download and install the Phone International plugin.
File
- src/
Commands/ PhoneInternationalCommands.php, line 192
Class
- PhoneInternationalCommands
- A Drush commandfile.
Namespace
Drupal\phone_international\CommandsCode
public function drushTarballExtract($path, $destination = FALSE) {
$this
->drushMkdir($destination);
$cwd = getcwd();
if (preg_match('/\\.tgz$/', $path)) {
drush_op('chdir', dirname($path));
$process = Drush::process([
'tar',
'-xvzf',
$path,
'-C',
$destination,
]);
$process
->run();
drush_op('chdir', $cwd);
if (!$process
->isSuccessful()) {
throw new \Exception(dt('Unable to extract !filename.' . PHP_EOL . implode(PHP_EOL, $process
->getOutput()), [
'!filename' => $path,
]));
}
}
else {
drush_op('chdir', dirname($path));
$process = Drush::process([
'unzip',
$path,
'-d',
$destination,
]);
$process
->run();
drush_op('chdir', $cwd);
if (!$process
->isSuccessful()) {
throw new \Exception(dt('Unable to extract !filename.' . PHP_EOL . implode(PHP_EOL, $process
->getOutput()), [
'!filename' => $path,
]));
}
}
}