Skip to content

Instantly share code, notes, and snippets.

@pemre
Created January 22, 2022 14:09
Show Gist options
  • Save pemre/149a36d32405dc9e0f7cdc98ea1f5de9 to your computer and use it in GitHub Desktop.
Save pemre/149a36d32405dc9e0f7cdc98ea1f5de9 to your computer and use it in GitHub Desktop.
// TODO You may put them under an npm package one day...
// --------------------------------------------------
const fs = require('fs');
const deleteFile = (filename) => {
try {
fs.unlinkSync(filename);
} catch (err) {
throw Error(err);
}
};
exports.deleteFile = deleteFile;
// --------------------------------------------------
const fs = require('fs');
const writeToFile = (filename, text) => {
fs.writeFileSync(filename, text, (err) => {
if (err) {
throw Error(err);
}
});
};
exports.writeToFile = writeToFile;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment