Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Modify the following:
- 1. replace readconfig contents with working copy
- 2. replace doczrc with value
- */
- let fs = require('fs');
- async function readConfig(){
- return await (new Promise(function(resolve, reject){
- resolve("Some value here");
- }));
- }
- async function modifyConfig(newValue){
- console.log('new value from git config is ', newValue);
- return await(new Promise((resolve, reject)=>{
- const file = require('./doczrc.js');
- fs.readFile("./doczrc.js", (err, body)=>{
- if(err){
- return reject(err);
- }
- body = body.toString();
- body = body.replace(file.base, newValue);
- console.log(file.base);
- fs.writeFile("./doczrc.js",body, (err)=>{
- if(err)
- return reject(err);
- console.log("completed")
- resolve(newValue);
- })
- })
- }))
- }
- readConfig().then((v)=>{
- modifyConfig(v).then((v)=>{
- console.log("replaced doczrc.js content with new value: ",v);
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement