Configuration API example in regular JavaScript?


#1

I’ve written my package in JavaScript and it’s working.

But I can’t find any examples of specifying configuration settings in such a package.

Can anybody share what I need to put in module.exports?

Thanks!


#2

Aha! I found a suitable example at: https://www.sitepoint.com/write-atom-packages-using-vanilla-javascript/

main.js

var config = require('./config-schema.json');
module.exports.config = config;

config-schema.json

{
  "activateHyperMode": {
    "description": "Turns the package into hyper mode.",
    "type": "boolean",
    "default": false
  },
  "setRange": {
    "type": "integer",
    "default": 42,
    "minium": 1,
    "maximum": 9000
  }
}