1.1.4 • Published 4 years ago

cfgread v1.1.4

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

CFGRead ( 1.1.4 )

This is a module for easily generating configuration files. Currently there are two supported formats, one I call "simple", the other is JSON. Besides generating configuration files, this module can also read configuration files.

Functions

format : Object

Kind: global variable

Example

format.SIMPLE
format.JSON

checkConfigFile(path) ⇒ boolean

Kind: global function

Returns: boolean - Returns true if the given configuration file exists, false if not.

ParamTypeDescription
pathstringThe path to the configuration file.

setFormat(format)

Kind: global function

Throws: Throws when an invalid format has been given.

ParamTypeDescription
formatformatThe format you'd like to use for your configuration file.

generateConfigFile(path, variables)

Generates a configuration file with a given set of variables. If no arguments are given, a default configuration file will be generated, which is empty.

Kind: global function

ParamTypeDescription
pathstringThe path to the configuration file. If no path has been given, a default path will be selected.
variablesArray.<string>The variables that you want people to be able to set in your configuration file.

Example

// Creates a file with the following content:
//	name1=value1
// 	name2=value2
//	name3=
let cfgread = require('cfgread');
cfgread.generateConfigFile("./config.cfg", ["name1", "value1"], ["name2", "value2"], "name3");

setConfigFile(path)

Kind: global function

Throws: Throws when an invalid string has been given.

ParamTypeDescription
pathstringThe path to the configuration file.

readConfigFile(path) ⇒ Object

Kind: global function

Returns: Object - Returns an object with the contents of the configuration file.

Throws: Throws when an invalid path has been given.

ParamTypeDescription
pathstringThe path to the configuration file. If no path is given, the default path will be used.

Example

// Output: { name1: 'value1', name2: 'value2', name3: NaN }
cfgread.generateConfigFile("./config.cfg", ["name1", "value1"], ["name2", "value2"], "name3");
let output = cfgread.readConfigFile("./config.cfg");
console.log(output);
1.1.4

4 years ago

1.1.1

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago