public function initConfig(OutputInterface $output = null)
    {
        $log = function ($message) use ($output) {
            if ($output) {
                $output->writeln($message);
            }
        };

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            throw new \RuntimeException('This feature is currently only supported on Linux and OSX (maybe). Please submit a PR to support it on windows.');
        }

        $configDir = $this->getConfigDir();
        $distDir = $this->getDistConfigDir();

        if (!$this->filesystem->exists($configDir)) {
            $log('<info>[+] Creating directory:</info> '.$configDir);
            $this->filesystem->mkdir($configDir);
        }

        $configFilenames = [
            'alias.yml',
            'phpcrsh.yml',
        ];

        foreach ($configFilenames as $configFilename) {
            $srcFile = $distDir.'/'.$configFilename;
            $destFile = $configDir.'/'.$configFilename;

            if (!$this->filesystem->exists($srcFile)) {
                throw new \Exception('Dist (source) file "'.$srcFile.'" does not exist.');
            }

            if ($this->filesystem->exists($destFile)) {
                $log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));

                return;
            }

            $this->filesystem->copy($srcFile, $destFile);
            $log('<info>[+] Creating file:</info> '.$destFile);
        }
    }
public function initConfig(OutputInterface $output = null)
    {
        $log = function ($message) use ($output) {
            if ($output) {
                $output->writeln($message);
            }
        };

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            throw new \RuntimeException('This feature is currently only supported on Linux and OSX (maybe). Please submit a PR to support it on windows.');
        }

        $configDir = $this->getConfigDir();
        $distDir = $this->getDistConfigDir();

        if (!$this->filesystem->exists($configDir)) {
            $log('<info>[+] Creating directory:</info> '.$configDir);
            $this->filesystem->mkdir($configDir);
        }

        $configFilenames = [
            'alias.yml',
            'phpcrsh.yml',
        ];

        foreach ($configFilenames as $configFilename) {
            $srcFile = $distDir.'/'.$configFilename;
            $destFile = $configDir.'/'.$configFilename;

            if (!$this->filesystem->exists($srcFile)) {
                throw new \Exception('Dist (source) file "'.$srcFile.'" does not exist.');
            }

            if ($this->filesystem->exists($destFile)) {
                $log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));

                return;
            }

            $this->filesystem->copy($srcFile, $destFile);
            $log('<info>[+] Creating file:</info> '.$destFile);
        }
    }
public function initConfig ( OutputInterface $ output = null ) { $ log = function ( $ message ) use ( $ output ) { if ( $ output ) { $ output -> writeln ( $ message ) ; } } ; if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { throw new \ RuntimeException ( 'This feature is currently only supported on Linux and OSX (maybe). Please submit a PR to support it on windows.' ) ; } $ configDir = $ this -> getConfigDir ( ) ; $ distDir = $ this -> getDistConfigDir ( ) ; if ( ! $ this -> filesystem -> exists ( $ configDir ) ) { $ log ( '<info>[+] Creating directory:</info> ' . $ configDir ) ; $ this -> filesystem -> mkdir ( $ configDir ) ; } $ configFilenames = [ 'alias.yml' , 'phpcrsh.yml' , ] ; foreach ( $ configFilenames as $ configFilename ) { $ srcFile = $ distDir . '/' . $ configFilename ; $ destFile = $ configDir . '/' . $ configFilename ; if ( ! $ this -> filesystem -> exists ( $ srcFile ) ) { throw new \ Exception ( 'Dist (source) file "' . $ srcFile . '" does not exist.' ) ; } if ( $ this -> filesystem -> exists ( $ destFile ) ) { $ log ( sprintf ( '<info>File</info> %s <info> already exists, not overwriting.' , $ destFile ) ) ; return ; } $ this -> filesystem -> copy ( $ srcFile , $ destFile ) ; $ log ( '<info>[+] Creating file:</info> ' . $ destFile ) ; } }
Initialize a configuration files.
Initialize a configuration files .