繁体   English   中英

如何在Directory中读取文件并存储在node.js的内存中

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

我有一个目录结构,如下所示:

Folder Structure 
        Config—folder

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

                App.json
                Config.properties

这里Config,10001,20001是文件夹。 我希望将逻辑实现为,如果我将Config作为根文件夹提供,则我的代码应扫描并生成如下输出:

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
}

使用程序包将如下所示:

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

PS:请不要将配置文件写入json :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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