I am building a custom module in NodeJS to load a key value from a config file. The module successfully reads and returns the config setting; however, if this is used later, it is always undefined.
hjson file
{
type: 'settings',
module: 'settings',
groupTitle: 'Settings',
groupIcon: 'fas fa-lg fa-database comp-data',
action: 'loadFromKey',
title: 'Load From Key',
icon: 'fas fa-lg fa-database comp-data',
dataScheme: [
{ name: 'Value', optionName: 'value', title: 'Value', initValue: true, defaultValue: false, type: 'text'}
],
dataPickObject: true,
globalVars: {},
properties: [
{
variables: [
{
name: 'name',
optionName: 'name',
title: 'Name',
type: 'text',
required: false,
defaultValue: 'name'
}
,{
name: 'output',
optionName: 'output',
title: 'Output',
type: 'boolean',
defaultValue: false
}
,{
name: 'actionKey',
optionName: 'key',
title: 'Key',
type: 'text',
required: true,
defaultValue: '',
serverDataBindings: true,
help: 'The config key.'
}
]
}
]
}
js file
const settings = require('../../../settings.json')
exports.loadFromKey = function(options, name) {
let configKey = this.parse(options.key, 'string', 'The config key is required.');
console.log(settings[configKey]);
return settings[configKey];
}
Custom module use