I'm currently working on a NPM script where I have a folder called "scripts" that contains all of my scripts. My goal is to check if there is a folder named "docs" at the root of the project, and if it exists, delete it. If not, then perform another task. I am utilizing fs-extra to interact with directories.
const fs = require('fs-extra');
const directory = 'docs';
try {
if (!fs.existsSync(directory)) {
fs.unlinkSync(directory);
console.log("Unwanted folder removed from the boilerplate.");
}
} catch (error) {
console.error(error);
}
I attempted to run this script, but unfortunately, it did not have any effect.