Skip to content

Node test config:check always returns 0 #1928

Closed
@doctorfree

Description

@doctorfree

Platform: electron@6.0.12, Raspberry Pi 4, Linux raspberrypi 4.19.97-v7l+

Node Version: v10.19.0

MagicMirror Version: 2.10.1

Description: The command "npm run config:check" always returns success regardless of the validity of the configuration file it is checking. The test is in the file tests/configs/check_config.js

Steps to Reproduce: Create an invalid config/config.js (e.g. delete the closing ] or } for a module) and run "npm run config:check" from a shell command prompt. After the npm command completes, run the command "echo $?". The output of "echo $?" is always 0 no matter which config file I check.

Expected Results: Checking valid configuration files should return 0 while checking invalid configurations should return 1 or other non-zero values.

Actual Results: The config:check test always returns 0

Configuration: I used a very simple config.js with the closing ] commented out:
modules: [
{
module: "alert",
},
{
module: "updatenotification",
position: "top_bar"
},
{
module: 'MMM-Remote-Control',
},
// ]

Additional Notes: This is a minor bug and would not effect most users. I am developing a command line script to manage my MagicMirror's many configuration files. One feature I have implemented is checking the validity of a configuration file before installing it. In order to do this programmatically in my script I needed to make the following one line change to the file tests/configs/check_config.js

*** check_config.js.orig 2020-02-10 14:29:40.399261804 -0800
--- check_config.js 2020-02-10 14:26:04.376118867 -0800


*** 61,66 ****
--- 61,67 ----
error = errors[idx];
console.log("Line", error.line, "col", error.character, error.reason);
}

  •       process.exit(1);
      }
    
    });
    }

Adding this call to process.exit(1) works for me but it may not be the best solution. I also found it cleaner, especially after this change, to run the config test with --silent option to npm:
npm run --silent config:check

My MagicMirror control script is in my Gitlab repository at https://gitlab.com/doctorfree/Scripts in the MagicMirror subdirectory at MagicMirror/mirror.sh

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions