src/Tasks.php
public function init() {
    $git_repo = exec('basename `git rev-parse --show-toplevel`');

    // Remove instructions for creating a new repo, because we've got one now.
    $readme_contents = file_get_contents('README.md');
    $start_string = '### Initial build (new repo)';
    $end_string = '### Initial build (existing repo)';
    $from = $this->findAllTextBetween($start_string, $end_string, $readme_contents);

    $find_replaces = array(
      array(
        'source' => 'composer.json',
        'from' => '"name": "thinkshout/drupal-project",',
        'to' => '"name": "thinkshout/' . $git_repo . '",',
      ),
      array(
        'source' => '.env.dist',
        'from' => 'TS_PROJECT="SITE"',
        'to' => 'TS_PROJECT="' . $git_repo . '"',
      ),
      array(
        'source' => 'README.md',
        'from' => array($from, 'new-project-name'),
        'to' => array($end_string, $git_repo),
      ),
    );

    foreach ($find_replaces as $find_replace) {
      $this->taskReplaceInFile($find_replace['source'])
        ->from($find_replace['from'])
        ->to($find_replace['to'])
        ->run();
    }
  }
public function init() {
    $git_repo = exec('basename `git rev-parse --show-toplevel`');

    // Remove instructions for creating a new repo, because we've got one now.
    $readme_contents = file_get_contents('README.md');
    $start_string = '### Initial build (new repo)';
    $end_string = '### Initial build (existing repo)';
    $from = $this->findAllTextBetween($start_string, $end_string, $readme_contents);

    $find_replaces = array(
      array(
        'source' => 'composer.json',
        'from' => '"name": "thinkshout/drupal-project",',
        'to' => '"name": "thinkshout/' . $git_repo . '",',
      ),
      array(
        'source' => '.env.dist',
        'from' => 'TS_PROJECT="SITE"',
        'to' => 'TS_PROJECT="' . $git_repo . '"',
      ),
      array(
        'source' => 'README.md',
        'from' => array($from, 'new-project-name'),
        'to' => array($end_string, $git_repo),
      ),
    );

    foreach ($find_replaces as $find_replace) {
      $this->taskReplaceInFile($find_replace['source'])
        ->from($find_replace['from'])
        ->to($find_replace['to'])
        ->run();
    }
  }
public function init ( ) { $ git_repo = exec ( 'basename `git rev-parse --show-toplevel`' ) ; // Remove instructions for creating a new repo, because we've got one now. $ readme_contents = file_get_contents ( 'README.md' ) ; $ start_string = '### Initial build (new repo)' ; $ end_string = '### Initial build (existing repo)' ; $ from = $ this -> findAllTextBetween ( $ start_string , $ end_string , $ readme_contents ) ; $ find_replaces = array ( array ( 'source' => 'composer.json' , 'from' => '"name": "thinkshout/drupal-project",' , 'to' => '"name": "thinkshout/' . $ git_repo . '",' , ) , array ( 'source' => '.env.dist' , 'from' => 'TS_PROJECT="SITE"' , 'to' => 'TS_PROJECT="' . $ git_repo . '"' , ) , array ( 'source' => 'README.md' , 'from' => array ( $ from , 'new-project-name' ) , 'to' => array ( $ end_string , $ git_repo ) , ) , ) ; foreach ( $ find_replaces as $ find_replace ) { $ this -> taskReplaceInFile ( $ find_replace [ 'source' ] ) -> from ( $ find_replace [ 'from' ] ) -> to ( $ find_replace [ 'to' ] ) -> run ( ) ; } }
Initialize the project for the first time.

@return \Robo\Result
Initialize the project for the first time .