File Tasks

Concat

Merges files into one. Used for preparing assets.

<?php
$this->taskConcat([
     'web/assets/screen.css',
     'web/assets/print.css',
     'web/assets/theme.css'
 ])
 ->to('web/assets/style.css')
 ->run()
?>

Replace

Performs search and replace inside a files.

<?php
$this->taskReplaceInFile('VERSION')
 ->from('0.2.0')
 ->to('0.3.0')
 ->run();

$this->taskReplaceInFile('README.md')
 ->from(date('Y')-1)
 ->to(date('Y'))
 ->run();

$this->taskReplaceInFile('config.yml')
 ->regex('~^service:~')
 ->to('services:')
 ->run();

$this->taskReplaceInFile('box/robo.txt')
 ->from(array('##dbname##', '##dbhost##'))
 ->to(array('robo', 'localhost'))
 ->run();
?>

TmpFile

Create a temporary file that is automatically cleaned up once the task collection is is part of completes. When created, it is given a random filename.

This temporary file may be manipulated exacatly like taskWrite(). It is deleted as soon as the collection it is a part of completes or rolls back.

<?php
$collection = $this->collectionBuilder();
$tmpFilePath = $collection->taskTmpFile()
     ->line('-----')
     ->line(date('Y-m-d').' '.$title)
     ->line('----')
     ->getPath();
$collection->run();
?>

Write

Writes to file.

<?php
$this->taskWriteToFile('blogpost.md')
     ->line('-----')
     ->line(date('Y-m-d').' '.$title)
     ->line('----')
     ->run();
?>