node-red-contrib-config-files
v0.3.0
Published
Read and merge configuration files (JSON).
Maintainers
Readme
node-red-contrib-config-files
Node-Red node for reading and merging configuration files with JSON content. The output returns the resulting configuration object.
Directory and filename extension used to search for configuration files can be configured using the node properties and/or with the input message.
The files are sorted by their file names and merged in this order. The defaultConfig can be used to define configuration
values that are used when they are missing in the configuration files.
If no configuration files are found, the defaultConfig is returned.
The node status displays one of the following two messages:
- Found {count} config files in '{configDir}' with extension '{configFileExt}'
- No config files found in '{configDir}' with extension '{configFileExt}' -> using default config
If directory configDir doesn't exist or is not accessible or if no file was found with configFileExt, node warnings
are created. These warnings may appear in the “Debug Messages” sidebar.
Special care is required when using config files containing arrays with objects: The concatArray property can be used
to define whether the array elements should be concatenated or merged. In the latter case, array elements with the same
array index are merged, i.e., element properties with identical names overwrite each other.
Internals
- This custom node was created from a subflow.
- It uses
lodash.merge()to merge thedefaultConfigwith the contents of the files found. - Some debug information is written by the node using
node.debug(). To view these messages, set the logging level insettings.jsto at leastdebug.
