1.0.2 • Published 7 years ago

@hkva/ezconfig v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

node-ezconfig

EZ Config Files with Node.JS :ok_hand:

Example:

const EZConfig = require('@hkva/ezconfig');

const DEFAULT_CONFIG = {
  _version: 1,
  token: 'Some information here',
  something: 12345,
  admins: [
    "me",
    "you",
    "your dog"
  ]
}

const config = new EZConfig('./config.json');

// Try to load the config from disk
if (!config.load()) {
  // Config could not be loaded
  console.error(`Config ${config.path} does not exist or could not be loaded`);
  // Reset to default
  config.reset(DEFAULT_CONFIG);
  console.log('Config reset');
  process.exit(1);
}

// Check config version

if (config.get('_version') < DEFAULT_CONFIG._version) {
  console.info('Warning: Config is out of date');
}

console.log(`token: ${config.get('token')}`);
console.log(`Admins: ${config.get('admins').join(' ')}`);
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago