Hi,
Is there a way to add folder programmatically in angular?
In the Assets folder I have Images folder, inside Images folder I need to automatically add folders based on user input data, is that possible and how?
import { access, mkdir } from "fs";
const path = "src/assets/images/newFolder/";
access(path, (error) => {
// To check if the given directory
// already exists or not
if (error) {
// If current directory does not exist
// then create it
mkdir(path, (error) => {
if (error) {
console.log(error);
} else {
console.log("New Directory created successfully !!");
}
});
} else {
console.log("Given Directory already exists !!");
}
});
I added the reference in angular.json:
"scripts": [
"src/assets/test.js"
]
and in ts file I have this:
declare function test(): any;
test();