[BUG] Programmatic access to config validator (via env vars) is out of scope #1663
Open
5 tasks done
Labels
🐛 Bug
[ISSUE] Ticket describing something that isn't working
Environment
Other (Specify below)
System
NixOS Unstable (Nixpkgs /b73c2221a46c13557b1b3be9c2070cc42cf01eb3)
Version
3.1.1+ (Git 0b1af9d)
Describe the problem
While attempting to package Dashy for NixOS, I tried to use
yarn validate-config
as part of the build process to validate that the configuration is correct before building the dashboard, which can often take several minutes.In order to stop the build, however, a command needs to exit with a non-zero exit code - and as it currently stands,
yarn validate-config
exits with0
whether or not the config is valid.Looking into the config validator, there appears to be an environment variable set if the configuration is valid. In practice (by inserting a
printenv
), the variable seems to either be unset or out of scope after the validator exits, which makes programmatic access to the status harder.Additional info
Using my (albeit limited) javascript knowledge, I tried to alter the validator script to exit with a non-zero code:
try { // Try to open and parse the YAML file config = yaml.load(fs.readFileSync(`./${process.env.USER_DATA_DIR || 'user-data'}/conf.yml`, 'utf8')); validate(config); } catch (e) { // Something went very wrong... setIsValidVariable(false); logToConsole(bigError()); printFileReadError(e); + process.exit(1); } module.exports = config;
...Which still seemed to exit with code
0
while config errors were present.Please tick the boxes
The text was updated successfully, but these errors were encountered: