pyconf.js
formerly node-config-python
Read and write python config files non-destructively (preserves comments and line-order)
Turns this kind of thing:
foo = Truebar = Nonebaz = whateverqux = apples,bananas
Into this kind of thing:
foo: true bar: null baz: "whatever" qux: "apples" "bananas"
(comments are stored in meta-data keys __lines
and __keys
)
Install
npm install --save pyconf
Usage
var pyconf = ; // alias for fs.readFile() then pyconf.parse()pyconf; // alias for pyconf.stringify() then safeReplace.writeFile()pyconf;
Note: the writeFile
function uses safe-replace
so that it will work even in environments where race conditions are possible and will also create a backup file whatever.conf.bak
of the config being overwritten.
API
pyconf // => err, object // => err, text // => err, object // => err