Sorry, I didn’t provide enough information.
I use /task.cfc
(running commands such as cfcompile
) to build the project.
Commandbox:pdm-server> task run
I set up some variables in /config/coldbox.cfc
:
// /config/coldbox.cfc
function configure() {
coldbox = {...},
settings = {
build = {
clientI18nFolder = "/Users/myleslee/websites/pdm-console/src/i18n",
syncI18nFiles = true,
...
}
}
}
/task.cfc
needs to access settings.build
which is also used by others, i.e. /models/SchemaService.cfc
.
// models/SchemaService.cfc
component singleton {
property name="buildSetting" inject="coldbox:setting:build";
...
}
I tried Luis’ suggestion but box:setting:build
didn’t work. It must point to somewhere else.
CommandBox DSL cannot find dependency using definition: {ref={null}, required={true}, argName={}, javaCast={null}, dsl={box:setting:build}, name={buildSetting}, type={any}, scope={variables}, value={null}}
The config setting requested: build does not exist in the loaded settings. Loaded settings are modules,server
So I went a verbose way to get the job done.
// /task.cfc
function run() {
var buildSetting = createObject("component", "config.coldbox").getBuildSetting()
...
}
// /config/coldbox.cfc
function getBuildSetting() {
return {
clientI18nFolder = "/Users/myleslee/websites/pdm-console/src/i18n",
syncI18nFiles = true,
...
}
}
function configure() {
coldbox = {...},
settings = {
build = getBuildSetting()
...
}
}
I know this might be a bad practice, so I would love to hear about how it is usually done from experienced ones.