Manage CLI application encrypted preferences.
npm install preferencesNode.JS Module for handling encrypted user preferences.
Designed for CLI applications.


``sh`
npm install --save preferences
`js
var Preferences = require("preferences");
// Init preference file with an unique identifier and an optional default data
var prefs = new Preferences('com.your.app.identifier',{
account: {
username: 'MrRobot',
password: 'fsociety'
},
test: {
cycles: 1
}
});
// Preferences can be accessed directly
prefs.test.cycles++;
console.log(prefs);
`
Preferences are automatically saved on disk before process exit.
You can override the default key path in the options:
`js`
var prefs = new Preferences('com.foo.bar',{}, {
key: '~/certs/my-custom-key.pem'
});
You can disable encryption for plain text preferences by setting encrypt to false.
`js`
var prefs = new Preferences('com.foo.bar',{}, {
encrypt: false
});
~/.config/preferences/com.foo.bar.pref`.`js
var prefs = new Preferences('com.foo.bar');
`$3
You can use the format option to specify the format for serialization. The supported types are `json` and `yaml`. This option is most useful when disabling encryption as it provides a human editable file.`js
var prefs = new Preferences('com.foo.bar',{}, {
encrypt: false,
file: path.join(path.dirname(process.cwd()), '.foo'),
format: 'yaml'
});
``MIT. Copyright (c) 2015 Caffeina.