new ConfigStore(fileNameopt, optionsopt) → {object}
- Source:
Creates an object to handle the config file. You can change the JSON file path for reading and writing by specifying the arguments.
Examples
// Ex.1: Default
var conf = new Wsh.ConfigStore();
// Equal with `new Wsh.ConfigStore(null, { dirPath: 'cwd' });`
conf.path; // %CD%\.wsh\settings.json
conf.store; // Returns: An Object in the above settings.json.
// Ex.2: Portable
var conf = new Wsh.ConfigStore(null, { dirPath: 'portable' });
conf.path; // <Wsh Script Directory>\.wsh\settings.json
// Ex.3: UserProfile
var conf = new Wsh.ConfigStore('myStore', { dirPath: 'userProfile' });
conf.path; // %USERPROFILE%\myStore.json
// Ex.4: Specifying absolute directory path
var conf = new Wsh.ConfigStore(null, { dirPath: 'D:\\conf' });
conf.path; // C:\conf\settings.json
// Can use the date literal
var conf = new Wsh.ConfigStore('vals_#{yy-MM}', { dirPath: 'D:\\confs' });
conf.path; // C:\confs\vals_20-08.json
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fileName |
string |
<optional> |
The JSON file name to read/write. |
||||||||||||
options |
object |
<optional> |
Optional parameters. Properties
|
Returns:
- Wsh.ConfigStore instance.
- Type
- object