Skip to content

Instantly share code, notes, and snippets.

@catalinpit
Created June 9, 2021 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catalinpit/badc2a539a44412892a0e05a9575d54d to your computer and use it in GitHub Desktop.
Save catalinpit/badc2a539a44412892a0e05a9575d54d to your computer and use it in GitHub Desktop.
const fs = require('fs');
const path = require('path');
fs.writeFile('content.txt', 'This is my first file!', (err) => {
if (err) {
throw err;
};
process.stdout.write('File created successfully!');
});
const filePath = path.join(process.cwd(), 'content.txt');
fs.readFile(filePath, (error, content) => {
if (error) throw error;
process.stdout.write(content);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment