nachos-settings-file
v1.0.3
Published
Settings file is a tool to handle nachos settings files
Downloads
14
Readme
settings-file
Settings file is a tool to handle nachos settings files
Have a problem? Come chat with us!
Installation
$ [sudo] npm install settings-file --save
Examples
Initialize
var SettingsFile = require('settings-file');
// Wraps /path/to/user/home/.nachos/data/test.json file
var settingsFile = new SettingsFile('test');
// Provide default settings
var settingsFile = new SettingsFile('test', {
globalDefaults: {color: 'blue'},
instanceDefaults: {color: 'red'}
});
Global Settings
// Read global settings
settingsFile.get()
.then(function(settings) {
// do stuff with settings
});
// Set selective fields
// file contents before: {color: 'blue', name: 'nacho'}
settingsFile.set({name: 'nyancat'})
.then(function() {
// saved!
// file contents after: {color: 'blue', name: 'nyancat'}
});
// Save settings (replaces existing settings)
// file contents before: {color: 'blue', name: 'nacho'}
settingsFile.save({name: 'nyancat'})
.then(function() {
// saved!
// file contents after: {name: 'nyancat'}
});
// Delete the file
settings.delete()
.then(function () {
// deleted!
});
Instance Settings
// Read instance settings
settingsFile
.instance(uuid)
.get()
.then(function(settings) {
// do stuff with settings
});
// Set selective fields
// instance contents before: {color: 'red', name: 'nacho'}
settingsFile
.instance(uuid)
.set({name: 'nyancat'})
.then(function() {
// saved!
// instance contents after: {color: 'red', name: 'nyancat'}
});
// Save settings (replaces existing settings)
// instance contents before: {color: 'red', name: 'nacho'}
settingsFile
.instance(uuid)
.save({name: 'nyancat'})
.then(function() {
// saved!
// instance contents after: {name: 'nyancat'}
});
// Delete the instance
settings
.instance(uuid)
.delete()
.then(function () {
// deleted!
});
Run Tests
$ npm test