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

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -