Skip to content

Commit

Permalink
Update my script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CitrixLab authored Sep 15, 2023
1 parent 34a11c5 commit 45d2eba
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions license/node/my script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ const fs = require('fs');
const path = require('path');

// Specify the folder and file details
const folderPath = 'file'; // Replace with your desired folder path
const folderPath = 'myFolder'; // Replace with your desired folder path
const fileName = 'example.txt';
const filePath = path.join(folderPath, fileName);
const fileContent = 'This is the content of the file.';

// Check if the folder exists
// Check if the folder exists, and create it if it doesn't
if (!fs.existsSync(folderPath)) {
console.log(`The folder "${folderPath}" does not exist.`);
// You can choose to create the folder here if needed using fs.mkdirSync(folderPath)
fs.mkdirSync(folderPath, { recursive: true }); // Create the folder and any missing parent folders
console.log(`The folder "${folderPath}" was created.`);
}

// Check if the file already exists
if (fs.existsSync(filePath)) {
console.log(`The file "${fileName}" already exists.`);
} else {
// Check if the file already exists
if (fs.existsSync(filePath)) {
console.log(`The file "${fileName}" already exists.`);
} else {
// Create the file
fs.writeFile(filePath, fileContent, (err) => {
if (err) {
console.error('Error creating the file:', err);
} else {
console.log('File created successfully.');
}
});
}
// Create the file
fs.writeFile(filePath, fileContent, (err) => {
if (err) {
console.error('Error creating the file:', err);
} else {
console.log('File created successfully.');
}
});
}

0 comments on commit 45d2eba

Please sign in to comment.