1

I am trying to figure out how the sequelize auto script works in the node_modules directory of a node project.

The very first statement has me stumped:

var sequelizeAuto = require('../');

I don't understand why or how this works [how can you include a whole directory as a package?

Perhaps the runner (npx sequelize-auto) provides a special environment? How do I figure it out?

github: sequelize-auto script

tjb
  • 11,480
  • 9
  • 70
  • 91
  • I'm not sure, but i think if the require-function does point to a directory instead of a single file, the directory will be searched for a index.js-file which will be used. – Olli Jun 13 '19 at 12:25

1 Answers1

1

Relative paths fallback to index.js if no file is mentioned.

var sequelizeAuto = require('../');

The above line is essentially a shorthand for :

var sequelizeAuto = require('../index.js');
tbking
  • 8,796
  • 2
  • 20
  • 33
  • This is missing the part which would describe how node handles symlinks in `.bin` (as otherwise `..` would point to `node_modules` instead of specific module). – Konstantin Pelepelin Feb 13 '20 at 15:05