簡體   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