Created
January 19, 2019 23:39
-
-
Save theptrk/ada41090cb7761f13f30342c7d0117ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const path = require('path') | |
const saveToFile = (entry) => { | |
const target = path.join(__dirname, 'did.txt') | |
console.log(chalk.green(`... saving to did.txt`)) | |
if (fs.existsSync(target)) { | |
// if the file exists, we will append to the existing file | |
return fs.appendFileSync(target, '\n\n' + entry); | |
} | |
else { | |
// if the file doesn't exist, we will write to a new file | |
return fs.writeFileSync(target, entry); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment