Simple and efficient way to create a complete filetree in one function. I created it to simplify the build process of my own framework (i know this information about my life is not usefull xD)
- Create the folders structure
- Create files
- Copy file
- Copy all files from a folder and subfolder
npm i @cafeine-software/arbo-crafter
import { buildFileTree } from ' @cafeine-software/arbo-crafter';
// ⬇ Define the structure of the filetree you want to create
const fileTreeStructure = {}
// ⬇ Where to create the filetree
const outputFolder = "out"
// ⬇ Will do nothing , look at example bellow :)
buildFileTree(fileTreeStructure,outputFolder)
Any object in the file tree structure definition will be considered as folder
const fileTreeStructure = {
folder1: {}
}
buildFileTree(fileTreeStructure,outputFolder)
// Result :
// - Create a folder 'folder1'
const fileTreeStructure = {
folder1:{
'example.txt':'example content'
}
}
buildFileTree(fileTreeStructure,outputFolder)
// Result :
// - Create a folder 'folder1'
// - Create a file 'example.txt' with content 'example content'
const fileTreeStructure = {
folder1:{
'example.txt':'example content',
'.gitignore.copy': `@.gitignore`,
}
}
buildFileTree(fileTreeStructure,outputFolder)
// Result :
// - Create a folder 'folder1'
// - Create a file 'example.txt' with content 'example content'
// - Copy file '.gitignore' as '.gitignore.copy'
Will copy all files from source folder but not the structure
const fileTreeStructure = {
folder1:{
'example.txt':'example content',
'.gitignore.copy': `@.gitignore`,
},
folderCopy:"@../../srcFolderPath"
}
buildFileTree(fileTreeStructure,outputFolder)
// Result :
// - Create a folder 'folder1'
// - Create a file 'example.txt' with content 'example content'
// - Copy file '.gitignore' as '.gitignore.copy'
// - Copy all files from folder '../../srcFolderPath' in 'folderCopy'
Developed by Quentin Lamamy, contact me on Linked In
Personal :
Cafeine Software :