diff --git a/src/Config/RootConfig.php b/src/Config/RootConfig.php index 3a512c5..921e5ff 100644 --- a/src/Config/RootConfig.php +++ b/src/Config/RootConfig.php @@ -30,12 +30,13 @@ protected function setOverride($key, $val) $key = ltrim($key, '-'); if ($key === 'template') { - $this->template = $this->fixPath($val); + $this->template = $val; return; } if ($key === 'target') { - $this->setTarget($val); + $this->target = rtrim($val, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + return; } } @@ -57,11 +58,7 @@ protected function initTarget() throw new Exception("No target set in '{$this->file}'."); } - $this->setTarget($this->json->target); - } - - protected function setTarget($target) - { + $target = $this->json->target; $target = rtrim($this->fixPath($target), DIRECTORY_SEPARATOR); $this->target = $target . DIRECTORY_SEPARATOR; } diff --git a/tests/Config/ConfigFactoryTest.php b/tests/Config/ConfigFactoryTest.php index 1d6022a..5a46426 100644 --- a/tests/Config/ConfigFactoryTest.php +++ b/tests/Config/ConfigFactoryTest.php @@ -40,14 +40,14 @@ public function testNewRootConfig() public function testNewRootConfigOverrides() { $overrides = array( - 'template' => md5(uniqid()), - 'target' => md5(uniqid()), + 'template' => "../../" . md5(uniqid()), + 'target' => "../../" . md5(uniqid()), ); $this->factory->setRootConfigOverrides($overrides); $config = $this->factory->newRootConfig($this->file, $this->data); $this->assertInstanceOf('Bookdown\Bookdown\Config\RootConfig', $config); - $this->assertSame("/path/to/{$overrides['template']}", $config->getTemplate()); - $this->assertSame("/path/to/{$overrides['target']}/", $config->getTarget()); + $this->assertSame("{$overrides['template']}", $config->getTemplate()); + $this->assertSame("{$overrides['target']}/", $config->getTarget()); } }