diff --git a/src/Commands/SetupCommand.php b/src/Commands/SetupCommand.php index 9c3ee8b..cb6de65 100644 --- a/src/Commands/SetupCommand.php +++ b/src/Commands/SetupCommand.php @@ -33,18 +33,14 @@ public function setup(Config $config) foreach ($configFiles as $type => $location) { $this->yell(sprintf('%s configuration (%s)', ucfirst($type), $location)); - if ( - file_exists($location) && $this->confirm( - sprintf('Would you like to regenerate the %s configuration file', $type) - ) - ) { - $this->createConfigYaml($location); - } elseif ( - $this->confirm( - sprintf('%s configuration file not found. Would you like to add one?', ucfirst($type)) - ) - ) { - $this->createConfigYaml($location); + if (file_exists($location)) { + if ($this->confirm(sprintf('Would you like to regenerate the %s configuration file', $type))) { + $this->createConfigYaml($location); + } + } else { + if ($this->confirm(sprintf('%s configuration file not found. Would you like to add one?', ucfirst($type)))) { + $this->createConfigYaml($location); + } } } } @@ -112,19 +108,18 @@ private function createConfigYaml($location) 'format' => 'Y-m-d H:i:s', 'taskwait' => 5, 'timeout' => 300, - 'configsyncdir' => 'sync', ], ]; $yaml = Yaml::dump($config, 3, 2); if (!is_dir(dirname($location))) { - mkdir(dirname($location), 700); + mkdir(dirname($location), 0700); } - if (!is_writable($location) && !@chmod($location, 0644)) { - $this->yell(sprintf('%s is not writeable', ucfirst($location)), 40, 'red'); - } elseif (file_put_contents($location, $yaml)) { + if (!is_writable(dirname($location)) && !@chmod(dirname($location), 0700)) { + $this->yell(sprintf('%s is not writeable', dirname($location)), 40, 'red'); + } elseif (file_put_contents($location, $yaml) && @chmod($location, 0644)) { $this->say(sprintf('Configuration file written to %s', $location)); } else { $this->say('Unable to write configuration file.');