Exemplo n.º 1
0
 /**
  * Move file.
  *
  * @param string $directory
  * @param null|string $name
  * @param bool $overwrite
  *
  * @return File
  */
 public function move($directory, $name = null, $overwrite = false)
 {
     $targetFile = $this->getTargetFile($directory, $name);
     $this->fileSystem->rename($this->getPathname(), $targetFile, $overwrite);
     $this->fileSystem->chmod($targetFile, 0666, umask());
     return $targetFile;
 }
 public static function createRequiredFiles(Event $event)
 {
     $fs = new Filesystem();
     $root = static::getDrupalRoot(getcwd());
     $dirs = ['modules', 'profiles', 'themes'];
     // Required for unit testing
     foreach ($dirs as $dir) {
         if (!$fs->exists($root . '/' . $dir)) {
             $fs->mkdir($root . '/' . $dir);
             $fs->touch($root . '/' . $dir . '/.gitkeep');
         }
     }
     // Prepare the settings file for installation
     if (!$fs->exists($root . '/sites/default/settings.php')) {
         $fs->copy($root . '/sites/default/default.settings.php', $root . '/sites/default/settings.php');
         $fs->chmod($root . '/sites/default/settings.php', 0666);
         $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666");
     }
     // Prepare the services file for installation
     if (!$fs->exists($root . '/sites/default/services.yml')) {
         $fs->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml');
         $fs->chmod($root . '/sites/default/services.yml', 0666);
         $event->getIO()->write("Create a sites/default/services.yml file with chmod 0666");
     }
     // Create the files directory with chmod 0777
     if (!$fs->exists($root . '/sites/default/files')) {
         $oldmask = umask(0);
         $fs->mkdir($root . '/sites/default/files', 0777);
         umask($oldmask);
         $event->getIO()->write("Create a sites/default/files directory with chmod 0777");
     }
 }
 /**
  * {@inheritdoc}
  */
 public function chmod($file, $mode)
 {
     try {
         $this->filesystem->chmod($this->getRealPathName($file), $mode);
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
Exemplo n.º 4
0
 /**
  * @param int $mode
  * @throws IOException
  * @return Dir
  */
 protected function ensureWritable($mode = 0777)
 {
     try {
         $this->io->mkdir($this->dir, $mode);
         $this->io->chmod($this->dir, $mode, 00, TRUE);
     } catch (SfException $e) {
         throw new IOException("Please make directory '{$this->dir}' writable, it cannot be done automatically", 0, $e);
     }
     return $this;
 }
Exemplo n.º 5
0
 protected function tearDown()
 {
     parent::tearDown();
     $this->filesystem->chmod(self::REMOTE_REPOSITORY_DIRECTORY, 0777, 00, true);
     $this->filesystem->remove(self::REMOTE_REPOSITORY_DIRECTORY);
     if (is_dir(self::LOCAL_REPOSITORY_DIRECTORY)) {
         $this->filesystem->chmod(self::LOCAL_REPOSITORY_DIRECTORY, 0777, 00, true);
         $this->filesystem->remove(self::LOCAL_REPOSITORY_DIRECTORY);
     }
 }
 /**
  * @override \ComponentManager\Step\Step
  *
  * @param \ComponentManager\Task\InstallTask $task
  */
 public function execute($task, LoggerInterface $logger)
 {
     $resolvedComponentVersions = $task->getResolvedComponentVersions();
     foreach ($resolvedComponentVersions as $resolvedComponentVersion) {
         $logger->info('Installing component', ['component' => $resolvedComponentVersion->getComponent()->getName(), 'packageRepository' => $resolvedComponentVersion->getPackageRepository()->getName(), 'version' => $resolvedComponentVersion->getVersion()->getVersion(), 'release' => $resolvedComponentVersion->getVersion()->getRelease()]);
         $projectLockFile = $this->project->getProjectLockFile();
         $component = $resolvedComponentVersion->getComponent();
         $packageSource = $this->project->getPackageSource($resolvedComponentVersion->getSpecification()->getPackageSource());
         $typeDirectory = $this->moodle->getPluginTypeDirectory($component->getPluginType());
         $targetDirectory = $this->platform->joinPaths([$typeDirectory, $component->getPluginName()]);
         $tempDirectory = $this->platform->createTempDirectory();
         $sourceDirectory = $packageSource->obtainPackage($tempDirectory, $resolvedComponentVersion, $this->filesystem, $logger);
         if ($resolvedComponentVersion->getFinalVersion() === null) {
             $logger->warning('Package source did not indicate final version; defaulting to desired version', ['version' => $resolvedComponentVersion->getVersion()->getVersion()]);
             $resolvedComponentVersion->setFinalVersion($resolvedComponentVersion->getVersion()->getVersion());
         }
         $logger->debug('Downloaded component source', ['packageSource' => $packageSource->getName(), 'sourceDirectory' => $sourceDirectory]);
         if ($this->filesystem->exists($targetDirectory)) {
             $logger->info('Component directory already exists; removing', ['targetDirectory' => $targetDirectory]);
             $this->filesystem->remove($targetDirectory);
         }
         $logger->info('Copying component source to Moodle directory', ['sourceDirectory' => $sourceDirectory, 'targetDirectory' => $targetDirectory]);
         $this->filesystem->mirror($sourceDirectory, $targetDirectory);
         $logger->info('Pinning component at installed final version', ['finalVersion' => $resolvedComponentVersion->getFinalVersion()]);
         $projectLockFile->addResolvedComponentVersion($resolvedComponentVersion);
         $logger->info('Cleaning up after component installation', ['tempDirectory' => $tempDirectory]);
         try {
             $this->filesystem->chmod([$tempDirectory], 0750, 00, true);
             $this->filesystem->remove([$tempDirectory]);
         } catch (IOException $e) {
             $logger->warning('Unable to clean up temporary directory', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'tempDirectory' => $tempDirectory]);
         }
     }
 }
 /**
  * Creates the container file from the discovered providers.
  *
  * @param Discovery $discovery
  */
 public static function compileContainer(Discovery $discovery)
 {
     $containerFile = self::getContainerFilePath();
     $compiler = new Compiler();
     $bindings = $discovery->findBindings('container-interop/DefinitionProviderFactories');
     $definitionProviders = [];
     $priorities = [];
     foreach ($bindings as $binding) {
         /* @var $binding ClassBinding */
         $definitionProviderFactoryClassName = $binding->getClassName();
         // From the factory class name, let's call the buildDefinitionProvider static method to get the definitionProvider.
         $definitionProviders[] = call_user_func([$definitionProviderFactoryClassName, 'buildDefinitionProvider'], $discovery);
         $priorities[] = $binding->getParameterValue('priority');
     }
     // Sort definition providers according to their priorities.
     array_multisort($priorities, $definitionProviders);
     foreach ($definitionProviders as $provider) {
         $compiler->register($provider);
     }
     $containerFileContent = $compiler->compile('\\TheCodingMachine\\Yaco\\Container');
     $filesystem = new Filesystem();
     if (!$filesystem->exists(dirname($containerFile))) {
         $filesystem->mkdir(dirname($containerFile));
     }
     $filesystem->dumpFile($containerFile, $containerFileContent);
     $filesystem->chmod($containerFile, 0664);
 }
Exemplo n.º 8
0
 /**
  * @return int 0 if OK, 1 if ERROR
  */
 public function installHooks()
 {
     try {
         if (!$this->filesystem->exists($this->hooksDestinationPath)) {
             $this->filesystem->mkdir($this->hooksDestinationPath);
         }
         $hooks = [];
         foreach (new \DirectoryIterator($this->hooksSourcePath) as $hook) {
             if ($hook->isDot()) {
                 continue;
             }
             $hooks[] = $hook->getFilename();
         }
         $this->progressBarInit(count($hooks));
         foreach ($hooks as $hook) {
             $sourceFile = $this->hooksSourcePath . '/' . $hook;
             $destinationFile = $this->hooksDestinationPath . '/' . $hook;
             $this->backupHook($destinationFile);
             $this->filesystem->copy($sourceFile, $destinationFile, true);
             $this->filesystem->chmod($destinationFile, 0755);
             $this->progressBarAdvance();
             $this->outputWriteln(" <info>Copying {$sourceFile} to {$destinationFile}</info>", true);
         }
         $this->progressBarFinish();
         $this->outputWriteln('');
         $this->outputWriteln(sprintf('<info>Hooks installed succesfully %s</info>', Constants::CHARACTER_THUMB_UP));
     } catch (\Exception $e) {
         $this->outputWriteln(" <error>" . $e->getMessage() . " Aborting</error>");
         return 1;
     }
     return 0;
 }
Exemplo n.º 9
0
 /**
  * Loads a container and returns it.
  *
  * If the cache file for the service container exists and is current, it
  * will be loaded and returned. Otherwise, a new container will be built
  * using the configuration file and the provided optional builder. The
  * builder will be used to make changes to the service container before
  * it is compiled and cached.
  *
  * It may be important to note that debug mode for the `ConfigCache` class
  * is enabled by default. This will ensure that cached configuration files
  * are updated whenever they are changed.
  *
  * @param string   $containerCacheFilePath     The container cache file path.
  * @param callable $containerBuilderCallable   The new container builder callable.
  * @param string   $compiledContainerClassName The compiled container class name.
  * @param boolean  $debug                      Is debugging mode enabled?
  *
  * @return Jarvis The loaded application.
  */
 public static function create($containerCacheFilePath, callable $containerBuilderCallable = null, $compiledContainerClassName = 'AppCachedContainer', $debug = true)
 {
     $cacheManager = new ConfigCache($containerCacheFilePath, $debug);
     if (!$cacheManager->isFresh()) {
         $container = static::createContainer();
         if (null !== $containerBuilderCallable) {
             $containerBuilderCallable($container);
         }
         if ($debug) {
             $filename = pathinfo($containerCacheFilePath, PATHINFO_DIRNAME) . '/' . pathinfo($containerCacheFilePath, PATHINFO_FILENAME) . '.xml';
             $container->setParameter('debug.container.dump', $filename);
         }
         $container->compile();
         $dumper = new PhpDumper($container);
         $cacheManager->write($dumper->dump(array('class' => $compiledContainerClassName)), $container->getResources());
         if ($debug) {
             $filename = $container->getParameter('debug.container.dump');
             $dumper = new XmlDumper($container);
             $filesystem = new Filesystem();
             $filesystem->dumpFile($filename, $dumper->dump(), null);
             try {
                 $filesystem->chmod($filename, 0666, umask());
             } catch (IOException $e) {
                 // discard chmod failure (some filesystem may not support it)
             }
         }
     }
     if (!class_exists($compiledContainerClassName)) {
         /** @noinspection PhpIncludeInspection */
         require $containerCacheFilePath;
     }
     return new Jarvis(new $compiledContainerClassName());
 }
Exemplo n.º 10
0
 /**
  * @param string $currentRevision
  * @param string $distantRevision
  */
 protected function upgrade($currentRevision, $distantRevision)
 {
     $fs = new Filesystem();
     $versionDir = sprintf('%s/versions', $this->config->get('twgit.protected.global.root_dir'));
     if (!is_dir($versionDir)) {
         mkdir($versionDir, 0755);
     }
     $newPharFile = sprintf('%s/twgit-%s.phar', $versionDir, $distantRevision);
     $oldPharFile = sprintf('%s/twgit-%s.phar-old', $versionDir, $currentRevision);
     $currentPharFile = realpath(str_replace(['phar://', '/src/NMR/Command'], ['', ''], __DIR__));
     $this->getLogger()->info('Download new version...');
     $this->getClient()->get(self::REMOTE_URL_PHAR, ['save_to' => $newPharFile]);
     if ($fs->exists($newPharFile)) {
         $this->getLogger()->info('Backup current version...');
         if ($fs->exists($oldPharFile)) {
             $fs->remove($oldPharFile);
         }
         $fs->rename($currentPharFile, $oldPharFile);
         $this->getLogger()->info('Install new version...');
         $fs->remove($currentPharFile);
         $fs->rename($newPharFile, $currentPharFile);
         $fs->chmod($currentPharFile, 0777);
     } else {
         $this->getLogger()->error('Failed to download new version.');
     }
 }
Exemplo n.º 11
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @throws Exception
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
     $tmpDir = dirname($localFilename);
     $tmpFilename = 'forge-cli-tmp.phar';
     $tmpFilepath = $tmpDir . '/' . $tmpFilename;
     if (!is_writable($tmpDir)) {
         throw new Exception('Forge update failed: "' . $tmpDir . '" is not writable. Try `sudo !!`.');
     }
     if (!is_writable($localFilename)) {
         throw new Exception('Forge update failed: "' . $localFilename . '" is not writable. Try `sudo !!`.');
     }
     $output->writeln('<info>Updating ' . $localFilename . '...</info>');
     $file = file_get_contents(self::SRC, false, $this->createStreamContext($output));
     $fs->dumpFile($tmpFilepath, $file, true);
     if ($fs->exists($tmpFilepath)) {
         $fs->rename($tmpFilepath, $localFilename, true);
         $fs->remove($tmpFilepath);
         $fs->chmod($localFilename, 0777);
         $output->writeln('<info>Update completed!</info>');
     } else {
         throw new Exception('Update Failed...');
     }
 }
Exemplo n.º 12
0
 protected function tearDown()
 {
     parent::tearDown();
     $filesystem = new Filesystem();
     // Ensure all files in the directory are writable before removing
     $filesystem->chmod($this->tempDir, 0755, 00, true);
     $filesystem->remove($this->tempDir);
 }
Exemplo n.º 13
0
 /**
  * Create default directories for domain.
  *
  * @param Domain $domain
  */
 public function createDirectories(Domain $domain)
 {
     $fs = new Filesystem();
     $dirs = array_merge(array($domain->getPath()), $this->_getDefaultDirs($domain->getPath()));
     $fs->mkdir($dirs, 0750);
     $fs->chmod($dirs, 0750);
     $this->_changeDirectoryOwner($domain);
 }
Exemplo n.º 14
0
 protected static function chmod($dir, $mode)
 {
     $filesystem = new Filesystem();
     try {
         $filesystem->chmod($dir, $mode);
     } catch (\Exception $e) {
     }
 }
Exemplo n.º 15
0
 public function write($content, array $metadata = null)
 {
     $mode = 0666;
     $umask = umask();
     $filesystem = new Filesystem();
     $filesystem->dumpFile($this->file, $content, null);
     try {
         $filesystem->chmod($this->file, $mode, $umask);
     } catch (IOException $e) {
     }
     if (null !== $metadata) {
         $filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null);
         try {
             $filesystem->chmod($this->getMetaFile(), $mode, $umask);
         } catch (IOException $e) {
         }
     }
 }
Exemplo n.º 16
0
 /**
  * Creates named temporary file
  *
  * @param $fileName
  * @param bool $preserve
  * @return \SplFileInfo
  * @throws \Exception
  */
 public function createFile($fileName, $preserve = false)
 {
     $this->initRunFolder();
     $fileInfo = new \SplFileInfo($this->tmpRunFolder . DIRECTORY_SEPARATOR . $fileName);
     $this->filesystem->touch($fileInfo);
     $this->files[] = array('file' => $fileInfo, 'preserve' => $preserve);
     $this->filesystem->chmod($fileInfo, 0600);
     return $fileInfo;
 }
Exemplo n.º 17
0
 /**
  * @param string          $directory
  * @param OutputInterface $output
  *
  * @throws AccessDeniedException if directory/file permissions cannot be changed
  */
 private function changePermissions($directory, OutputInterface $output)
 {
     try {
         $this->filesystem->chmod($directory, 0755, 00, true);
         $output->writeln(sprintf('<comment>Changed "%s" permissions to 0755.</comment>', $directory));
     } catch (IOException $exception) {
         throw new AccessDeniedException(dirname($directory));
     }
 }
 /**
  * Create directory
  * @param string $directory
  */
 private function createDirectory($directory)
 {
     if (!$this->filesystem->exists($directory)) {
         $this->filesystem->mkdir($directory);
     }
     $directory = new \SplFileInfo($directory);
     if (!$directory->isWritable()) {
         $this->filesystem->chmod($directory->getRealPath(), 0777);
     }
 }
Exemplo n.º 19
0
 /**
  * @param object              $item
  * @param FeedTypeInterface[] $types
  * @param bool                $force
  *
  * @return bool
  */
 public function cacheItem($item, array $types = [], $force = false)
 {
     if (false === $this->supports($item)) {
         return false;
     }
     if (empty($types)) {
         $types = $this->getTypesForItem($item);
     }
     foreach ($types as $type) {
         $template = $type->getTemplate();
         $cacheFile = $this->getItemCacheFilename($item, $type);
         if (!file_exists($cacheFile) || $force) {
             $xml = $this->getWriter($type)->renderItem($item, $template);
             $this->filesystem->dumpFile($cacheFile, $xml, null);
             $this->filesystem->chmod($cacheFile, 0666, umask());
         }
     }
     return true;
 }
Exemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function chmod($paths, int $mode, int $umask = 00, bool $recursive = false)
 {
     try {
         $this->filesystem->chmod($paths, $mode, $umask, $recursive);
     } catch (IOException $exception) {
         throw new FilesystemException($exception->getMessage(), $exception->getPath(), $exception);
     } catch (Exception $exception) {
         throw new FilesystemException($exception->getMessage(), null, $exception);
     }
 }
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function NotWritable_ThrowException()
 {
     $fs = new Filesystem();
     $fs->remove(self::$kernelCacheDir);
     $fs->mkdir(self::$kernelCacheDir, 00);
     $this->initContainer();
     $this->container->compile();
     $fs->chmod(self::$kernelCacheDir, 7777);
     $fs->remove(self::$kernelCacheDir);
 }
Exemplo n.º 22
0
 protected function tearDown()
 {
     $fs = new Filesystem();
     try {
         $fs->chmod([$this->root, $this->file], 0755);
     } catch (IOException $e) {
         // ignore exception
     }
     $fs->remove($this->root);
 }
Exemplo n.º 23
0
 /**
  * @param string $name
  * @param string $operation
  * @param array  $configuration
  */
 private function buildConfig($name, $operation, array $configuration)
 {
     $upperOperation = strtoupper($operation);
     $path = sprintf('%s/%s.%s', $this->pathBuild, $name, $operation);
     list($operationSkl, $functionSkl, $caseSkl, $mainSkl) = $this->getSkeletons($operation);
     $content = $operationSkl;
     $contentMain = $mainSkl;
     $contentFunctions = '';
     $contentCases = '';
     foreach ($configuration['connections'] as $connectionName => $connection) {
         list($function, $case) = $this->buildConnection($operation, $connectionName, $connection, $functionSkl, $caseSkl);
         $contentFunctions .= $function;
         $contentCases .= $case;
     }
     $content = str_replace(sprintf('__%s_FUNCTIONS__', $upperOperation), $contentFunctions, $content);
     $contentMain = str_replace('__CASES__', $contentCases, $contentMain);
     $content = str_replace(sprintf('__%s_MAIN__', $upperOperation), $contentMain, $content);
     $this->fileSystem->dumpFile($path, $content);
     $this->fileSystem->chmod($path, 0775);
 }
Exemplo n.º 24
0
 /**
  * Writes cache.
  *
  * @param string              $content  The content to write in the cache
  * @param ResourceInterface[] $metadata An array of ResourceInterface instances
  *
  * @throws \RuntimeException When cache file can't be wrote
  */
 public function write($content, array $metadata = null)
 {
     $mode = 0666;
     $umask = umask();
     $filesystem = new Filesystem();
     $filesystem->dumpFile($this->file, $content, null);
     try {
         $filesystem->chmod($this->file, $mode, $umask);
     } catch (IOException $e) {
         // discard chmod failure (some filesystem may not support it)
     }
     if (null !== $metadata && true === $this->debug) {
         $filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null);
         try {
             $filesystem->chmod($this->getMetaFile(), $mode, $umask);
         } catch (IOException $e) {
             // discard chmod failure (some filesystem may not support it)
         }
     }
 }
Exemplo n.º 25
0
 public function testChmodChangesZeroModeOnSubdirectoriesOnRecursive()
 {
     $this->markAsSkippedIfChmodIsMissing();
     $directory = $this->workspace . DIRECTORY_SEPARATOR . 'directory';
     $subdirectory = $directory . DIRECTORY_SEPARATOR . 'subdirectory';
     mkdir($directory);
     mkdir($subdirectory);
     chmod($subdirectory, 00);
     $this->filesystem->chmod($directory, 0753, 00, true);
     $this->assertEquals(753, $this->getFilePermissions($subdirectory));
 }
Exemplo n.º 26
0
 /**
  *
  */
 public function configure()
 {
     $fs = new Filesystem();
     $fs->chmod(Platform::webDir() . '/sites/default', 0775);
     $fs->chmod(Platform::webDir() . '/sites/default/settings.php', 0664);
     if ($this->version == DrupalStackHelper::DRUPAL7) {
         $fs->copy(CLI_ROOT . '/resources/stacks/drupal/drupal7.settings.php', Platform::webDir() . '/sites/default/settings.php', true);
     } elseif ($this->version == DrupalStackHelper::DRUPAL8) {
         $fs->copy(CLI_ROOT . '/resources/stacks/drupal/drupal8.settings.php', Platform::webDir() . '/sites/default/settings.php', true);
     }
     if ($this->version == DrupalStackHelper::DRUPAL8) {
         $fs->mkdir([Platform::sharedDir() . '/config', Platform::sharedDir() . '/config/active', Platform::sharedDir() . '/config/staging']);
     }
     $fs->dumpFile(Platform::sharedDir() . '/settings.local.php', $this->string);
     // Relink if missing.
     if (!$fs->exists(Platform::webDir() . '/sites/default/settings.local.php')) {
         $fs->symlink('../../../shared/settings.local.php', Platform::webDir() . '/sites/default/settings.local.php');
     }
     $this->drushrc();
 }
Exemplo n.º 27
0
 public function process(ContainerBuilder $container)
 {
     $filename = self::getCompilerLogFilename($container);
     $filesystem = new Filesystem();
     $filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null);
     try {
         $filesystem->chmod($filename, 0666, umask());
     } catch (IOException $e) {
         // discard chmod failure (some filesystem may not support it)
     }
 }
Exemplo n.º 28
0
 public function testChmodChangesModeOfTraversableFileObject()
 {
     $directory = $this->workspace . DIRECTORY_SEPARATOR . 'directory';
     $file = $this->workspace . DIRECTORY_SEPARATOR . 'file';
     $files = new \ArrayObject(array($directory, $file));
     mkdir($directory);
     touch($file);
     $this->filesystem->chmod($files, 0753);
     $this->assertEquals(753, $this->getFilePermisions($file));
     $this->assertEquals(753, $this->getFilePermisions($directory));
 }
 public static function create($kernelRootDir, Filesystem $filesystem)
 {
     $branchLogoDir = realpath($kernelRootDir . '/../web') . Logo::PATH_TO_LOGO_DIR;
     if (!$filesystem->exists($branchLogoDir)) {
         $filesystem->mkdir($branchLogoDir);
     }
     $branchLogoDir = new \SplFileInfo($branchLogoDir);
     if (!$branchLogoDir->isWritable()) {
         $filesystem->chmod($branchLogoDir->getRealPath(), 0777);
     }
     return new BranchLogoHandler($branchLogoDir, $filesystem);
 }
Exemplo n.º 30
-20
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $gitHooksPath = $this->paths()->getGitHooksDir();
     $resourceHooksPath = $this->paths()->getGitHookTemplatesDir() . $this->grumPHP->getHooksPreset();
     $resourceHooksPath = $this->paths()->getPathWithTrailingSlash($resourceHooksPath);
     $customHooksPath = $this->paths()->getPathWithTrailingSlash($this->grumPHP->getHooksDir());
     // Some git clients to not automatically create a git hooks folder.
     if (!$this->filesystem->exists($gitHooksPath)) {
         $this->filesystem->mkdir($gitHooksPath);
         $output->writeln(sprintf('<fg=yellow>Created git hooks folder at: %s</fg=yellow>', $gitHooksPath));
     }
     foreach (self::$hooks as $hook) {
         $gitHook = $gitHooksPath . $hook;
         $hookTemplate = $resourceHooksPath . $hook;
         if ($customHooksPath && $this->filesystem->exists($customHooksPath . $hook)) {
             $hookTemplate = $customHooksPath . $hook;
         }
         if (!$this->filesystem->exists($hookTemplate)) {
             throw new \RuntimeException(sprintf('Could not find hook template for %s at %s.', $hook, $hookTemplate));
         }
         $content = $this->parseHookBody($hook, $hookTemplate);
         file_put_contents($gitHook, $content);
         $this->filesystem->chmod($gitHook, 0775);
     }
     $output->writeln('<fg=yellow>Watch out! GrumPHP is sniffing your commits!<fg=yellow>');
 }