1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 00:20:08 +01:00

change to preg replace instead of sed

This commit is contained in:
Taylor Otwell
2016-05-08 23:50:01 -05:00
parent e25be02c69
commit 677ff7ae5b
3 changed files with 12 additions and 7 deletions

View File

@@ -7,7 +7,7 @@
class PhpFpm
{
var $brew, $cli;
var $brew, $cli, $files;
var $taps = [
'homebrew/dupes', 'homebrew/versions', 'homebrew/homebrew-php'
@@ -18,12 +18,14 @@ class PhpFpm
*
* @param Brew $brew
* @param CommandLine $cli
* @param Filesystem $files
* @return void
*/
function __construct(Brew $brew, CommandLine $cli)
function __construct(Brew $brew, CommandLine $cli, Filesystem $files)
{
$this->cli = $cli;
$this->brew = $brew;
$this->files = $files;
}
/**
@@ -47,9 +49,12 @@ function install()
*/
function updateConfiguration()
{
$this->cli->quietly('sed -i "" -E "s/^user = .+$/user = '.user().'/" '.$this->fpmConfigPath());
$contents = $this->files->get($this->fpmConfigPath());
$this->cli->quietly('sed -i "" -E "s/^group = .+$/group = staff/" '.$this->fpmConfigPath());
$contents = preg_replace('/^user = .+$/m', 'user = '.user(), $contents);
$contents = preg_replace('/^group = .+$/m', 'group = staff', $contents);
$this->files->put($this->fpmConfigPath(), $contents);
}
/**

View File

@@ -85,8 +85,8 @@ public function test_has_installed_php_indicates_if_php_is_installed_via_brew()
public function test_tap_taps_the_given_homebrew_repository()
{
$cli = Mockery::mock(CommandLine::class);
$cli->shouldReceive('passthru')->once()->with('sudo -u Taylor brew tap php70');
$cli->shouldReceive('passthru')->once()->with('sudo -u Taylor brew tap php56');
$cli->shouldReceive('passthru')->once()->with('sudo -u '.user().' brew tap php70');
$cli->shouldReceive('passthru')->once()->with('sudo -u '.user().' brew tap php56');
swap(CommandLine::class, $cli);
resolve(Brew::class)->tap('php70', 'php56');
}

View File

@@ -45,7 +45,7 @@ public function test_install_installs_and_places_configuration_files_in_proper_l
$this->assertEquals('address=/.dev/127.0.0.1'.PHP_EOL, file_get_contents(__DIR__.'/output/custom-dnsmasq.conf'));
$this->assertEquals('test-contents
conf-file=/Users/'.user().'/Documents/Code/Valet/tests/output/custom-dnsmasq.conf
conf-file='.__DIR__.'/output/custom-dnsmasq.conf
', file_get_contents(__DIR__.'/output/dnsmasq.conf'));
}