Skip to content
Snippets Groups Projects
Commit c13aa510 authored by VILLAUME Lucas's avatar VILLAUME Lucas
Browse files

Gestion IO des fichiers

parent 026d1e4a
No related branches found
No related tags found
No related merge requests found
/node_modules /node_modules
\ No newline at end of file /test
\ No newline at end of file
const fs = require('fs');
function writeFile(document){
const data = JSON.stringify(document.toJSON());
const directoryPath = `storage/${document.auteur}`;
if (!fs.existsSync(directoryPath)) {
fs.mkdirSync(directoryPath, { recursive: true });
}
fs.writeFile(`${directoryPath}/${document.nom}.json`,data, (err) => {
if (err){
console.log(err);
throw err;
}
});
}
module.exports = { writeFile };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment