Advertisement
Guest User

Untitled

a guest
May 26th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. /*
  2. Modify the following:
  3. 1. replace readconfig contents with working copy
  4. 2. replace doczrc with value
  5. */
  6. let fs = require('fs');
  7. async function readConfig(){
  8. return await (new Promise(function(resolve, reject){
  9. resolve("Some value here");
  10. }));
  11. }
  12. async function modifyConfig(newValue){
  13. console.log('new value from git config is ', newValue);
  14. return await(new Promise((resolve, reject)=>{
  15. const file = require('./doczrc.js');
  16.  
  17. fs.readFile("./doczrc.js", (err, body)=>{
  18. if(err){
  19. return reject(err);
  20. }
  21. body = body.toString();
  22. body = body.replace(file.base, newValue);
  23. console.log(file.base);
  24. fs.writeFile("./doczrc.js",body, (err)=>{
  25. if(err)
  26. return reject(err);
  27. console.log("completed")
  28. resolve(newValue);
  29. })
  30. })
  31. }))
  32. }
  33. readConfig().then((v)=>{
  34. modifyConfig(v).then((v)=>{
  35. console.log("replaced doczrc.js content with new value: ",v);
  36. })
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement