Browserify: how you will read the contents of the directory

In my current Browserify project, I need the ability to scroll through folders of a specific directory and receive a json file from each. Therefore, I will need some kind of module fs.

Are there any specific modules that you can recommend to play well with Browserify and let me use readdirsync/ readdiror another method to read the contents of another directory?

Apparently, I cannot use the regular nodejs module fs, and I looked through brfs , but that only gives me access to readFile.

I would like to do something like:

// app.js
getFiles = require('./getFiles.js')():

and

// getFiles.js
module.exports = function(){
  var fs = require('some_module_system');

  var folders = fs.readdir('../path/to/dir', function(err, contents){
    console.log(contents);
  });
}

and wrap everything with

browserify app.js > build.js
+4
1

brfs . readdir readdirSync ( fs ).

brfs:

npm install --save brfs

"some_module_system" "fs" ( brfs ).

:

browserify -t brfs app.js > build.js 

.

+1

Source: https://habr.com/ru/post/1545030/


All Articles