Skip to content

Commit

Permalink
fix: broken .env resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Korzunin committed Sep 11, 2021
1 parent bf2d03b commit 93ff453
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions plop/index.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import { findSync } from './utils';
import config from './config.json';
import * as models from './models';

const dirname = findSync(process.cwd(), ['{{relativeOutputDir}}', '{{slsRelativeOutputDir}}'], ['d'], ['d'], 1)[0] || __dirname;

const loadedEnv = tryLoadEnvs({
rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(dirname, config.relativeEnvPaths.rootEnvPath),
schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(dirname, config.relativeEnvPaths.schemaEnvPath),
rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(__dirname, config.relativeEnvPaths.rootEnvPath),
schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(__dirname, config.relativeEnvPaths.schemaEnvPath),
});
const env = { ...(loadedEnv ? loadedEnv.parsed : {}), ...process.env };
const databaseUrl = config.datasource.url.fromEnvVar
Expand Down
6 changes: 2 additions & 4 deletions prisma/sequelize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import { findSync } from './utils';
import config from './config.json';
import * as models from './models';

const dirname = findSync(process.cwd(), ['prisma/sequelize', 'sequelize'], ['d'], ['d'], 1)[0] || __dirname;

const loadedEnv = tryLoadEnvs({
rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(dirname, config.relativeEnvPaths.rootEnvPath),
schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(dirname, config.relativeEnvPaths.schemaEnvPath),
rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(__dirname, config.relativeEnvPaths.rootEnvPath),
schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(__dirname, config.relativeEnvPaths.schemaEnvPath),
});
const env = { ...(loadedEnv ? loadedEnv.parsed : {}), ...process.env };
const databaseUrl = config.datasource.url.fromEnvVar
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ generatorHandler({
// datasourceNames: options.datasources.map((d) => d.name),
datasource: options.datasources[0],
};
const relativeOutputDir = path.relative(process.cwd(), outputDir);
const slsRelativeOutputDir = path.relative(process.cwd(), outputDir).split(path.sep).slice(1).join(path.sep);
// const relativeOutputDir = path.relative(process.cwd(), outputDir);
// const slsRelativeOutputDir = path.relative(process.cwd(), outputDir).split(path.sep).slice(1).join(path.sep);

const enumIndex = indexBy(prop('name'), options.dmmf.datamodel.enums ?? []);

Expand All @@ -59,8 +59,6 @@ generatorHandler({
indexGenerator.runActions({
models: options.dmmf.datamodel.models,
config: JSON.stringify(config, null, 2),
relativeOutputDir,
slsRelativeOutputDir,
}),
...options.dmmf.datamodel.models.map((model) => {
const attributes = model.fields.map((field) => field.name);
Expand Down

0 comments on commit 93ff453

Please sign in to comment.