Made Silencer invocations safer against exceptions.

main
Niels Keurentjes 9 years ago
parent 2c3e7cf5f2
commit c2e768b8ad

@ -159,18 +159,16 @@ EOT
$this->authConfigSource = new JsonConfigSource($this->authConfigFile, true); $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
// Initialize the global file if it's not there, ignoring any warnings or notices // Initialize the global file if it's not there, ignoring any warnings or notices
Silencer::suppress();
if ($input->getOption('global') && !$this->configFile->exists()) { if ($input->getOption('global') && !$this->configFile->exists()) {
touch($this->configFile->getPath()); touch($this->configFile->getPath());
$this->configFile->write(array('config' => new \ArrayObject)); $this->configFile->write(array('config' => new \ArrayObject));
chmod($this->configFile->getPath(), 0600); Silencer::call('chmod', $this->configFile->getPath(), 0600);
} }
if ($input->getOption('global') && !$this->authConfigFile->exists()) { if ($input->getOption('global') && !$this->authConfigFile->exists()) {
touch($this->authConfigFile->getPath()); touch($this->authConfigFile->getPath());
$this->authConfigFile->write(array('http-basic' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject)); $this->authConfigFile->write(array('http-basic' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject));
chmod($this->authConfigFile->getPath(), 0600); Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
} }
Silencer::restore();
if (!$this->configFile->exists()) { if (!$this->configFile->exists()) {
throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile)); throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));

@ -225,13 +225,11 @@ EOT
chdir($oldCwd); chdir($oldCwd);
$vendorComposerDir = $composer->getConfig()->get('vendor-dir').'/composer'; $vendorComposerDir = $composer->getConfig()->get('vendor-dir').'/composer';
if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) { if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
Silencer::suppress(); Silencer::call('rmdir', $vendorComposerDir);
rmdir($vendorComposerDir);
$vendorDir = $composer->getConfig()->get('vendor-dir'); $vendorDir = $composer->getConfig()->get('vendor-dir');
if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) { if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
rmdir($vendorDir); Silencer::call('rmdir', $vendorDir);
} }
Silencer::restore();
} }
return 0; return 0;

Loading…
Cancel
Save