Skip to content

Commit 4998f6b

Browse files
committed
Can now operate with no config file present.
1 parent b2f5e1b commit 4998f6b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Bootstrap.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
function Boot( string $ConfigPath ) : Application
1717
{
1818
/** @var Neuron\Data\Setting\Source\ISettingSource $Settings */
19-
$Settings = new Yaml( "$ConfigPath/config.yaml" );
2019

21-
$BasePath = $Settings->get( 'system', 'base_path' );
20+
try
21+
{
22+
$Settings = new Yaml( "$ConfigPath/config.yaml" );
23+
$BasePath = $Settings->get( 'system', 'base_path' );
24+
}
25+
catch( Exception $e )
26+
{
27+
$Settings = null;
28+
$BasePath = getenv( 'SYSTEM_BASE_PATH' ) ? : '.';
29+
}
2230

2331
$Version = new Version();
2432
$Version->loadFromFile( "$BasePath/version.json" );

tests/BootstrapTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,12 @@ public function testBootstrap()
1515
Dispatch( $App );
1616
}
1717

18+
public function testMissingConfig()
19+
{
20+
$cwd = getcwd();
21+
$App = Boot( 'examples/non-there' );
22+
$this->assertTrue( is_object( $App ) );
1823

24+
Dispatch( $App );
25+
}
1926
}

0 commit comments

Comments
 (0)