MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    (2.1.0, API) Option to set the minimum version number of the MagicMirror framework for your module.

    Scheduled Pinned Locked Moved Upcoming Features
    1 Posts 1 Posters 2.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MichMichM Offline
      MichMich Admin
      last edited by MichMich

      In version 2.1.0 (the current develop branche) the module and nodeHelper API both feature the requiresVersion variable. This allows you to set the minimum version number of the MagicMirror framework that is necessary for your module to run correctly. This is important, because version 2.1.0 will contain some API changes that might prevent your module from running in older versions.

      More information about this feature can be found here: https://github.com/MichMich/MagicMirror/tree/develop/modules#requiresversion

      Example code:

      Module.register("testModule", {
      
          requiresVersion: "2.1.0",
      
          start: function() {
             // do something
          }
      });
      

      Of course, this feature would be way more powerfull if it was available starting from version 2.0.0. Unfortunately I did not have the time yet to invent a time machine. Therefor you can use a workaround if you really must do some manual checking. Starting from version 2.1.0, the frontend javascript will have a global variable called version. This is a string that represents the current version of the MagicMirror. In the node helper, this string is available via global.version.

      So, if absolutely necessary, you can use the following code in your module:

      // main module
      if (!version) {
          // this is an old version, give the user a warning and don't perform any other new API calls.
      }
      
      // node helper
      if (!gobal.version) {
          // this is an old version, give the user a warning and don't perform any other new API calls.
      }
      

      Since this feature is still in the develop branch, it’s not final and might change. Suggestions are welcome.

      1 Reply Last reply Reply Quote 3
      • 1 / 1
      • First post
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy