src/Tasks/BuildAsset.php
public function run(): Robo\Result
    {
        // Touch the destination so that "realpath" works.
        $result = $this->collectionBuilder()->taskFilesystemStack()
            ->mkdir($this->destination->getPath())
            ->touch($this->destination->getPathname())
        ->run()->wasSuccessful();

        // Plus this should error out early if we can't write to the file
        if (!$result)
        {
            throw new RuntimeException
            (
                'We can not write to the destination file: '.
                $this->destination->getPathname()
            );
        }

        // Initialise the asset, this is what we will eventually
        // write to the file-system at the end of this method.
        $asset_contents = '';

        // Loop through the source files
        foreach ($this->source as $file)
        {
            // Tell the world what we are doing
            $this->printTaskInfo('Compiling - <info>'.$file.'</info>');

            // Run the compiler for each file
            $asset_contents .= $this->getCompiler(new SplFileInfo($file))->compile();
        }

        // Bust some cache balls
        if ($this->cachebust === true)
        {
            $this->bustCacheBalls($asset_contents);
        }

        // Now write the asset
        $this->writeAsset($asset_contents);

        // If we get to here assume everything worked
        return \Robo\Result::success($this);
    }
public function run(): Robo\Result
    {
        // Touch the destination so that "realpath" works.
        $result = $this->collectionBuilder()->taskFilesystemStack()
            ->mkdir($this->destination->getPath())
            ->touch($this->destination->getPathname())
        ->run()->wasSuccessful();

        // Plus this should error out early if we can't write to the file
        if (!$result)
        {
            throw new RuntimeException
            (
                'We can not write to the destination file: '.
                $this->destination->getPathname()
            );
        }

        // Initialise the asset, this is what we will eventually
        // write to the file-system at the end of this method.
        $asset_contents = '';

        // Loop through the source files
        foreach ($this->source as $file)
        {
            // Tell the world what we are doing
            $this->printTaskInfo('Compiling - <info>'.$file.'</info>');

            // Run the compiler for each file
            $asset_contents .= $this->getCompiler(new SplFileInfo($file))->compile();
        }

        // Bust some cache balls
        if ($this->cachebust === true)
        {
            $this->bustCacheBalls($asset_contents);
        }

        // Now write the asset
        $this->writeAsset($asset_contents);

        // If we get to here assume everything worked
        return \Robo\Result::success($this);
    }
public function run ( ) : Robo \ Result { // Touch the destination so that "realpath" works. $ result = $ this -> collectionBuilder ( ) -> taskFilesystemStack ( ) -> mkdir ( $ this -> destination -> getPath ( ) ) -> touch ( $ this -> destination -> getPathname ( ) ) -> run ( ) -> wasSuccessful ( ) ; // Plus this should error out early if we can't write to the file if ( ! $ result ) { throw new RuntimeException ( 'We can not write to the destination file: ' . $ this -> destination -> getPathname ( ) ) ; } // Initialise the asset, this is what we will eventually // write to the file-system at the end of this method. $ asset_contents = '' ; // Loop through the source files foreach ( $ this -> source as $ file ) { // Tell the world what we are doing $ this -> printTaskInfo ( 'Compiling - <info>' . $ file . '</info>' ) ; // Run the compiler for each file $ asset_contents .= $ this -> getCompiler ( new SplFileInfo ( $ file ) ) -> compile ( ) ; } // Bust some cache balls if ( $ this -> cachebust === true ) { $ this -> bustCacheBalls ( $ asset_contents ) ; } // Now write the asset $ this -> writeAsset ( $ asset_contents ) ; // If we get to here assume everything worked return \ Robo \ Result :: success ( $ this ) ; }
The main run method.

```php
$this->taskBuildAsset('/path/to/asset.js')
->source
([
'/path/to/asset1.js',
'/path/to/asset2.js',
'/path/to/asset3.js',
'/path/to/assetetc.js'
])
->run();
```
@return Robo\Result
The main run method .