mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 16:40:05 +01:00
change to preg replace instead of sed
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class PhpFpm
|
class PhpFpm
|
||||||
{
|
{
|
||||||
var $brew, $cli;
|
var $brew, $cli, $files;
|
||||||
|
|
||||||
var $taps = [
|
var $taps = [
|
||||||
'homebrew/dupes', 'homebrew/versions', 'homebrew/homebrew-php'
|
'homebrew/dupes', 'homebrew/versions', 'homebrew/homebrew-php'
|
||||||
@@ -18,12 +18,14 @@ class PhpFpm
|
|||||||
*
|
*
|
||||||
* @param Brew $brew
|
* @param Brew $brew
|
||||||
* @param CommandLine $cli
|
* @param CommandLine $cli
|
||||||
|
* @param Filesystem $files
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct(Brew $brew, CommandLine $cli)
|
function __construct(Brew $brew, CommandLine $cli, Filesystem $files)
|
||||||
{
|
{
|
||||||
$this->cli = $cli;
|
$this->cli = $cli;
|
||||||
$this->brew = $brew;
|
$this->brew = $brew;
|
||||||
|
$this->files = $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,9 +49,12 @@ function install()
|
|||||||
*/
|
*/
|
||||||
function updateConfiguration()
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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()
|
public function test_tap_taps_the_given_homebrew_repository()
|
||||||
{
|
{
|
||||||
$cli = Mockery::mock(CommandLine::class);
|
$cli = Mockery::mock(CommandLine::class);
|
||||||
$cli->shouldReceive('passthru')->once()->with('sudo -u Taylor brew tap php70');
|
$cli->shouldReceive('passthru')->once()->with('sudo -u '.user().' brew tap php70');
|
||||||
$cli->shouldReceive('passthru')->once()->with('sudo -u Taylor brew tap php56');
|
$cli->shouldReceive('passthru')->once()->with('sudo -u '.user().' brew tap php56');
|
||||||
swap(CommandLine::class, $cli);
|
swap(CommandLine::class, $cli);
|
||||||
resolve(Brew::class)->tap('php70', 'php56');
|
resolve(Brew::class)->tap('php70', 'php56');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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('address=/.dev/127.0.0.1'.PHP_EOL, file_get_contents(__DIR__.'/output/custom-dnsmasq.conf'));
|
||||||
$this->assertEquals('test-contents
|
$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'));
|
', file_get_contents(__DIR__.'/output/dnsmasq.conf'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user