@iutlannion/charger-dossier
v1.0.7
Published
Module generating a JavaScript object tree corresponding to the folders and files in a given folder where each property is either a subfolder or file whose value is the files list as an object or what the file returned or contains.
Downloads
9
Maintainers
Readme
charger-dossier
This module loads all JavaScript files in a folder and its subfolders and generates an object which represents the file tree where each folder is an object and each file a variable whose value is what the file returned or contains.
Quick start
You only have to require the module and then give it a folder name:
const chargerDossier = require("charger-dossier")
const myFolder = chargerDossier("./myfoldername")
console.log(myFolder instance of Object) // true
console.log(myFolder.mySubFolder.myScriptFile) // prints the `exports`ed value
console.log(myFolder.mySubFolder.myTextFile) // prints the file content (if activated in the options, see below)
Options
The module waits for a required parameter folderName
and an optional second parameter options
object.
Options are:
Warning
The behavior of this module is undefined if it encounters both a folder and a file with the same name (extension apart). You should not do that as one will overwrite the other one.