RobinCK / typeorm-fixtures

:pill: Fixtures loader for typeorm 🇺🇦
https://robinck.github.io/typeorm-fixtures/
MIT License
566 stars 45 forks source link

Feature request: add process.env to parameters #101

Closed doomsower closed 4 years ago

doomsower commented 4 years ago

I'm generating my fixtures programmatically and I'd like to use environment variables in fixtures like this: id: '<{process.env.ADMIN_USER_ID}>'. Currently I have to manually modify parameters like this:

  loader.load(path.resolve(__dirname, process.env.NODE_ENV));
  const configs = loader.fixtureConfigs;
  configs.forEach((cfg) => {
    if (cfg.entity === 'User') {
      set(cfg, 'cfg.parameters.userIds.admin', process.env.ADMIN_USER_ID);
    }
  });

It would be nice to have process.env added to parameters by default. I've looked at the sources and could not decide where it fits.

grexlort commented 4 years ago

I'm also interested in that feature or another way to include global parameters for all fixtures - e.g userId that is used in another microservice