Missing environments are now reported
This commit is contained in:
parent
2bcda8e7d5
commit
7de74415df
27
env.inc.php
27
env.inc.php
|
@ -7,14 +7,19 @@ $GLOBALS['TASKMAN_ROOT_ENV_NAME'] = 'gamectl.props.php';
|
||||||
task('envs', function()
|
task('envs', function()
|
||||||
{
|
{
|
||||||
global $GAME_ROOT;
|
global $GAME_ROOT;
|
||||||
$dir = $GAME_ROOT."/env/";
|
$dir = normalize_path($GAME_ROOT."/env/", true);
|
||||||
|
|
||||||
echo "=== Available envs ===\n";
|
echo "=== Available envs ===\n";
|
||||||
|
|
||||||
$results = scan_files_rec(array($dir), array(".props.php"));
|
$results = scan_files_rec(array($dir), array(".props.php"));
|
||||||
|
|
||||||
foreach($results as $file)
|
foreach($results as $file)
|
||||||
echo str_replace(".props.php", "", str_replace($dir, "", $file)) . "\n";
|
{
|
||||||
|
$file = str_replace($dir, '', normalize_path($file, true));
|
||||||
|
$file = str_replace(".props.php", '', $file);
|
||||||
|
$file = ltrim($file, '/');
|
||||||
|
echo $file . "\n";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function put_env(&$argv)
|
function put_env(&$argv)
|
||||||
|
@ -63,12 +68,9 @@ function include_env()
|
||||||
global $GAME_ROOT;
|
global $GAME_ROOT;
|
||||||
|
|
||||||
$env_filename = get_env_file();
|
$env_filename = get_env_file();
|
||||||
$root_env = get_root_env_name();
|
|
||||||
|
|
||||||
if($env_filename && !file_exists($env_filename))
|
if($env_filename && !file_exists($env_filename))
|
||||||
throw new Exception("Error setting environment. No such env file $env_filename");
|
throw new Exception("No env file '$env_filename'");
|
||||||
else if($env_filename === null && file_exists("$GAME_ROOT/$root_env"))
|
|
||||||
$env_filename = "$GAME_ROOT/$root_env";
|
|
||||||
|
|
||||||
if($env_filename)
|
if($env_filename)
|
||||||
include($env_filename);
|
include($env_filename);
|
||||||
|
@ -83,13 +85,14 @@ function get_env_file()
|
||||||
$env = getenv("GAME_ENV");
|
$env = getenv("GAME_ENV");
|
||||||
|
|
||||||
if($env)
|
if($env)
|
||||||
|
{
|
||||||
$env_filename = "$GAME_ROOT/env/$env.props.php";
|
$env_filename = "$GAME_ROOT/env/$env.props.php";
|
||||||
else
|
|
||||||
$env_filename = "$GAME_ROOT/" . get_root_env_name();
|
|
||||||
|
|
||||||
if(file_exists($env_filename))
|
|
||||||
return $env_filename;
|
return $env_filename;
|
||||||
|
}
|
||||||
return null;
|
|
||||||
|
//checking optional env.file
|
||||||
|
$env_filename = "$GAME_ROOT/" . get_root_env_name();
|
||||||
|
|
||||||
|
return file_exists($env_filename) ? $env_filename : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue