Quick and dirty loading/saving of JSON files.
var settings_access = require('command-line-config') var settings = settings_access.load('./some_file.json') settings.dumb = false settings_access.save(settings, './some_file.json')
All paths are interpreted relative to the current working directory.
If you don't specify a path to load, the module assumes the file was passed in via the command-line, like so:
node your-script.js config-file.json
var settings = settings_access.load() settings.wat = "WHERE DID YOU COME FROM" settings_access.save(settings)
Which command-line argument will be interpreted as a file to be opened? The first one to resolve to an actual file, of course!
All file-system interactions are done synchronously, which means you most likely only want to be interacting with it when your app launches/terminates (which is the most likely use case anyway).
Written for ISoft Data Systems, licensed WTFPL.