Advertisement
Guest User

Untitled

a guest
May 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /**
  2. * mkLocalCfg function,
  3. * makes a local config directory structure and empty config file.
  4. * in the form "~/.config/nobjs/nobjs_config.json"
  5. *
  6. * @param {mkLocalCfgCallback} cb - The callback that handles the response.
  7. *
  8. */
  9. function mkLocalCfg(cb) {
  10. //validate root folder exists, if not make it.
  11. if (!admin.hasHomeConfigDir()) {
  12. fs.mkdir(os.homedir() + "/.config", "775", function(err) {
  13. //stop here if you can't make it.
  14. if (err) {cb(err); return;}
  15. });
  16. }
  17. fs.mkdir(admin.getConfigLocation(false), "775", function(err) {
  18. //can't make config folder end it here
  19. if (err) {cb(err); return;}
  20. //write config file, return null or err on error
  21. fs.writeFile(admin.getConfigLocation(true), JSON.stringify({blogs: {}}), function(err) {
  22. if (err) {cb(err); return;}
  23. cb(null);
  24. });
  25. });
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement