mirror of
https://github.com/DevL0rd/SkyNX
synced 2024-11-23 11:33:05 +00:00
21 lines
532 B
JavaScript
21 lines
532 B
JavaScript
|
//Authour: Dustin Harris
|
||
|
//GitHub: https://github.com/DevL0rd
|
||
|
var fs = require('fs');
|
||
|
var getDirName = require('path').dirname;
|
||
|
|
||
|
function load(path) {
|
||
|
var contents = fs.readFileSync(path).toString('utf-8');
|
||
|
return JSON.parse(contents)
|
||
|
}
|
||
|
|
||
|
function save(path, obj) {
|
||
|
var contents = JSON.stringify(obj, null, "\t")
|
||
|
fs.mkdir(getDirName(path), { recursive: true }, function (err) {
|
||
|
if (err) throw err;
|
||
|
fs.writeFileSync(path, contents, function (err) {
|
||
|
if (err) throw err;
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
exports.load = load;
|
||
|
exports.save = save;
|