thisOldDave
02/17/2022, 3:37 PMsknowlton
02/17/2022, 3:42 PMsknowlton
02/17/2022, 3:42 PM/**
* Load up common and local env files
*/
function loadEnvVars() {
// Load common config from any xxx.env files in the config dir
if ( fileExists( './config/#getSystemSetting( 'ENVIRONMENT' )#.env' ) ) {
command( 'dotenv load' )
.params( resolvepath( './config/#getSystemSetting( 'ENVIRONMENT' )#.env' ) )
.run();
}
else {
print.line( 'No environment file found matching ./config/' & getSystemSetting( 'ENVIRONMENT' ) & '.env' );
}
// Re-load any .env file so it can override the common settings above
if ( fileExists( resolvepath( '../.env' ) ) ) {
command( 'dotenv load' )
.params( resolvepath( '../.env' ) )
.run( returnOutput = true );
}
}
thisOldDave
02/17/2022, 3:44 PMbdw429s
02/17/2022, 7:24 PM.env
file in the SAME folder as your task.cfc
?bdw429s
02/17/2022, 7:25 PMcalling the task.cfc in a subdirectory, that subdirectory has a .env fileThis sounds like that's a "yes"
bdw429s
02/17/2022, 7:25 PMbdw429s
02/17/2022, 7:25 PMtask run
) will automatically find and load any .env
file prior to execution.bdw429s
02/17/2022, 7:26 PMdotenv load
command if you have other property files in other folders or with other names that you also want loaded.bdw429s
02/17/2022, 7:29 PMcd subdir/
box task run
in your shell script, then you should be goodbdw429s
02/17/2022, 7:30 PMbox task run taskFile=subdir/task.cfc
THEN dotenv is going to look in the working directory that the command was run, not the directory that the task happened to live in elsewhere on the hard drive.thisOldDave
02/18/2022, 8:44 AM