Hotfile
Usage
instantiation
const { Hotfolder, Hotfile, Hot } = require('hotfile')
const dirpath = './myfolder'
const filepath = './myfile.txt'
const myfolder = new Hotfolder(dirpath)
const myfile = new Hotfile(filepath)
0. place your code in an asycn function
const someAsyncFucn = async () => {
}
1. Create sub-folders
const sub1folder = await myfolder.createFolder('subfolder-01')
const sub2folder = await myfolder.createFolder('subfolder-02')
2. Create file in folder
const file = await subfolder.create('summer.js')
3. Move file to another folder
await file.setNameTo('water').setBasenameTo('nemo.mp4').moveTo(sub2folder)
4. Load subfolders with their files
await myfolder.laodChildren()
5. Load subfolders, their files and for callback for each child
const cb = async (item) => {
if(item.isFile){
}else {
}
}
await myfolder.laodChildren({cb})
6. Ignore children that are included
await myfolder.laodChildren({
cb,
exclude: ['node_modules', 'exact_name_of_unwated_file', 'DS_Store']
})
7. Exclude all hidden files
await myfolder.laodChildren({
cb,
deny: [ /(^|\/)\.[^\/\.]/g, /.*\.mp4/g]
})