javascript - How can I require modules with patterns in the path? -


how can include files in nodejs like

require('./packages/city/model/cities') require('./packages/state/model/states') require('./packages/country/model/countries') 

like

require('./packages/*/model/*') 

same grunt loading files.

you can't (or @ least shouldn't)

in order this, have overload node's native require function, highly inadvisable.

the commonjs pattern might seem tedious you, it's 1 , shouldn't try break because saw shortcuts in other languages/frameworks.

by introducing form of magic in module, change programmers can (and should able to) safely assume commonjs pattern itself.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -