Initialize a directory as a project root.

@param string $directory
The Git repository that should be initialized.
@param Project $project
The project.
166603
public function mapDirectory($directory, Project $project)
    {
        if (!file_exists($directory . '/.git')) {
            throw new \InvalidArgumentException('Not a Git repository: ' . $directory);
        }
        $projectConfig = [
            'id' => $project->id,
        ];
        if ($host = parse_url($project->getUri(), PHP_URL_HOST)) {
            $projectConfig['host'] = $host;
        }
        $this->writeCurrentProjectConfig($projectConfig, $directory, true);
        $this->ensureGitRemote($directory, $project->getGitUrl());
    }
180568
protected function createDirectory($directory)
    {
        if (!$this->files->isDirectory($directory)) {
            $this->files->makeDirectory($directory, 0755, true);
        }
    }
1371777
private function checkFileBeforeInitialize($directory, $file)
    {
        $filePath = $directory . '/' . $file;

        if (file_exists($filePath)) {
            throw new IOException(sprintf(
                'The file "%s" already exist.',
                $filePath
            ));
        }

        touch($filePath);
    }
1033222
protected function constructDefault($filename, Dir $directory=NULL) {
    $this->setName($filename);
    
    if (isset($directory)) 
      $this->setDirectory($directory);
  }
1050008
public function askProjectDir(
        InputInterface $input,
        OutputInterface $output,
        $dir = null,
        SymfonyStyle $style = null
    ) {
        $question = $this->getSimpleQuestion()
            ->getQuestion('Please set your root project directory.', $dir);
        $question->setValidator(
            $this->getValidator()
        );

        $style = $style ?: new SymfonyStyle($input, $output);
        $dir   = $style->askQuestion($question);

        return rtrim($dir, '\\/');
    }
1194241
public static function initialize(?string $path = null): void
    {
        if (self::$isLoaded === true) {
            return;
        }

        // Load dotenv.
        self::$path = $path;
        if (self::$path === null) {
            self::$path = Path::root();
        }
        if (File::exist(self::$path . '/.env')) {
            self::$dotenv = new Dotenv(self::$path);
            self::$dotenv->load();
        }

        // Initialize repositories.
        if (!is_array(self::$repositories)) {
            self::$repositories = [];
        }

        self::$isLoaded = true;
    }
932022
public function setDirectory($directory = __DIR__)
    {
        if (!is_dir($directory)) {
            $message = "Directory {$directory} doesn't exist.";
            throw new \RuntimeException($message);
        }
        $this->directory = $directory;
        $this->gitattributesFile = $directory
            . DIRECTORY_SEPARATOR
            . '.gitattributes';

        return $this;
    }
334944
private function initPath($path, $args = null)
    {
        $this->info("Init directory '{$path}'");

        $repositoryUrl = trim(shell_exec("cd {$path} && git config --get remote.origin.url"));
        $packageName = $this->getPackageNameByRepositoryUrl($repositoryUrl);

        $this->initComposerJson($path, $repositoryUrl, $packageName);
        $this->initPackageClassPhp($path, $packageName);

        if (!$this->noTests) {
            $this->initPhpUnitXml($path);
            $this->initPackageClassTestPhp($path, $packageName);
        }

        if (!$this->noCi) {
            $this->initCodeclimateYml($path);
            $this->initTravisYml($path);
            $this->initStyleCiYml($path);
        }
    }
764667
def init_current_directory():
    """"""
    settings_directory=project_path+'/.dry'
    settings_file=settings_directory+'/config.py'
    if os.path.isdir(settings_directory):
	# already initialized
	print("directory already initialized.")
	return
    # init
    os.makedirs(settings_directory)
    f = open(settings_file,'w')
    print(sample_config_file, file=f)
    f.close()
1310529
public function initialize($vendor, $package, $directory)
    {
        if (!$this->files->exists($directory) || !$this->files->isDirectory($directory)) {
            throw new InvalidPathException("{$directory} does not exist or is not a valid directory.");
        }

        $packageComposer = new Package;
        $packageComposer->setVendor($vendor);
        $packageComposer->setPackage($package);
        $packageComposer->setDescription('Give your package template a good description');
        $packageComposer->setLicense(user_config('configuration.license', ''));
        $packageComposer->setAuthors(user_config('configuration.authors', []));

        $writer = new ConfigurationWriter($packageComposer->toArray());
        $writer['config'] = (object)['vendor-dir' => '_newup_vendor'];

        $writer->save($directory.'/composer.json');
        $this->renderer->setData('package', $package);
        $this->renderer->setData('vendor', $vendor);

        $packageClass = $this->renderer->render('template');

        if (!$this->files->exists($directory.'/_newup/')) {
            $this->files->makeDirectory($directory.'/_newup/');
        }

        if ($this->shouldCreateTemplateDirectory && $this->files->exists($directory.'/_template') == false) {
            $this->files->makeDirectory($directory.'/_template');
        }

        $this->files->put($directory.'/_newup/Package.php', $packageClass);
    }
1029017
protected function mkDir($dir)
    {
        if (!file_exists($dir)) {
            mkdir($dir, self::DIR_MODE, true);
            chmod($dir, self::DIR_MODE);
        }
        if (!is_dir($dir)) {
            throw new \Exception("Failed to create directory: $dir");
        }
    }
635484
public function setDirectory($directory)
	{
		$this->directory = $directory;

		// Set the finder to use this directory as well
		$this->finder->in($directory);

		return $this;
	}
37526
public function initializeTemplate($directory = null)
	{
		if (empty($directory)) {
			$directory = $this->config->resolvePath('views');
		}

		$this->template = new Template($directory);
	}
1036628
public function setProjectId($projectId = '')
    {
        $this->projectId = $projectId;
        $this->_debug->info(__FUNCTION__, 'setProjectId: ', $this->projectId);
    }
367398
def set_project_dir(self, directory):
        """"""
        if directory is not None:
            self.treewidget.set_root_path(osp.dirname(directory))
            self.treewidget.set_folder_names([osp.basename(directory)])
        self.treewidget.setup_project_view()
        try:
            self.treewidget.setExpanded(self.treewidget.get_index(directory),
                                        True)
        except TypeError:
            pass
311659
public static function init($directory, array $params = null) {
		if(is_dir("$directory/.git")) {
			throw new ShellException("Repo already exists in $directory.");
		}
		if(!is_dir($directory) && !@mkdir($directory, 0777, true)) // intentionally @; not atomic; from Nette FW
		{
			throw new ShellException("Unable to create directory '$directory'.");
		}
		$cwd = getcwd();
		chdir($directory);
		exec(self::processCommand([
			'git init',
			$params,
			$directory,
		]), $output, $returnCode);
		if($returnCode !== 0) {
			throw new ShellException("Git init failed (directory $directory).");
		}
		$repo = getcwd();
		chdir($cwd);
		return new static($repo);
	}
449775
public function initAndCommitRepo() {
    // The .git dir will already exist if blt-project was created using a
    // branch. Otherwise, it will not exist when using a tag.
    if (!file_exists($this->getConfigValue("repo.root") . "/.git")) {
      $result = $this->taskGit()
        ->dir($this->getConfigValue("repo.root"))
        ->exec("git init")
        ->commit('Initial commit.', '--allow-empty')
        ->add('-A')
        ->commit('Created BLT project.')
        ->interactive(FALSE)
        ->printOutput(FALSE)
        ->printMetadata(FALSE)
        ->run();

      if (!$result->wasSuccessful()) {
        throw new BltException("Could not initialize new git repository.");
      }
    }
  }