简体   繁体   中英

How to read files inside Directory and store in memory in node.js

I have a Directory structure as following:

Folder Structure 
        Config—folder

                10001—folder
                        20001—folder
                            20001.properties
                   10001.properties                         

                App.json
                Config.properties

here Config,10001,20001 are folders. i want a logic to be implemented as, if i give Config as a Root folder, then my code should scan and generate output as following:

Config.Config.properties : {
here it should have the config.propertis values
}

Config.App.json : {
    here it should have the config.propertis values
}

Config.10001.10001.properties : {
here it should have the 10001.propertis values
}

Config.10001.20001.20001.properties : {
here it should have the 20001.propertis values
}

Using this package it'll look like that:

require('require_tree').require_tree('./Config', {preserve_filenames: true})

PS: please don't write your config files in json :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM