Skip to content

Commit b7fb7f2

Browse files
Phillip9587FrozenPandaz
authored andcommitted
feat(core): updated dotenv and switched to import 'dotenv/config' (#5615)
1 parent 15ea35d commit b7fb7f2

File tree

17 files changed

+38
-58
lines changed

17 files changed

+38
-58
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
"cz-customizable": "^6.2.0",
131131
"depcheck": "^1.3.1",
132132
"document-register-element": "^1.13.1",
133-
"dotenv": "8.2.0",
133+
"dotenv": "~10.0.0",
134134
"ejs": "^3.1.5",
135135
"eslint": "7.10.0",
136136
"eslint-config-next": "^11.0.1",

packages/cypress/src/executors/cypress/cypress.impl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import { basename, dirname, join } from 'path';
23
import { installedCypressVersion } from '../../utils/cypress-version';
34
import {
@@ -37,10 +38,6 @@ export interface CypressExecutorOptions extends Json {
3738
testingType?: 'component' | 'e2e';
3839
}
3940

40-
try {
41-
require('dotenv').config();
42-
} catch (e) {}
43-
4441
export default async function cypressExecutor(
4542
options: CypressExecutorOptions,
4643
context: ExecutorContext

packages/jest/src/executors/jest/jest.impl.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import { runCLI } from 'jest';
23
import { readConfig } from 'jest-config';
34
import { utils as jestReporterUtils } from '@jest/reporters';
@@ -9,15 +10,7 @@ import { ExecutorContext, TaskGraph } from '@nrwl/devkit';
910
import { join } from 'path';
1011
import { getSummary } from './summary';
1112

12-
try {
13-
require('dotenv').config();
14-
} catch (e) {
15-
// noop
16-
}
17-
18-
if (process.env.NODE_ENV === null || process.env.NODE_ENV === undefined) {
19-
(process.env as any).NODE_ENV = 'test';
20-
}
13+
process.env.NODE_ENV ??= 'test';
2114

2215
export async function jestExecutor(
2316
options: JestExecutorOptions,

packages/next/src/executors/build/build.impl.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import { ExecutorContext } from '@nrwl/devkit';
23

34
import build from 'next/dist/build';
@@ -18,16 +19,12 @@ import {
1819
} from '@nrwl/workspace/src/utilities/buildable-libs-utils';
1920
import { assertDependentProjectsHaveBeenBuilt } from '../../utils/buildable-libs';
2021

21-
try {
22-
require('dotenv').config();
23-
} catch (e) {}
24-
2522
export default async function buildExecutor(
2623
options: NextBuildBuilderOptions,
2724
context: ExecutorContext
2825
) {
2926
let dependencies: DependentBuildableProjectNode[] = [];
30-
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
27+
process.env.NODE_ENV ||= 'production';
3128

3229
const root = resolve(context.root, options.root);
3330

packages/next/src/executors/export/export.impl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import {
23
ExecutorContext,
34
parseTargetString,
@@ -19,10 +20,6 @@ import {
1920
} from '@nrwl/workspace/src/utilities/buildable-libs-utils';
2021
import { assertDependentProjectsHaveBeenBuilt } from '../../utils/buildable-libs';
2122

22-
try {
23-
require('dotenv').config();
24-
} catch (e) {}
25-
2623
export default async function exportExecutor(
2724
options: NextExportBuilderOptions,
2825
context: ExecutorContext

packages/next/src/executors/server/server.impl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import {
23
ExecutorContext,
34
logger,
@@ -30,10 +31,6 @@ import {
3031
} from '@nrwl/workspace/src/utilities/buildable-libs-utils';
3132
import { assertDependentProjectsHaveBeenBuilt } from '../../utils/buildable-libs';
3233

33-
try {
34-
require('dotenv').config();
35-
} catch (e) {}
36-
3734
const infoPrefix = `[ ${chalk.dim(chalk.cyan('info'))} ] `;
3835
const readyPrefix = `[ ${chalk.green('ready')} ]`;
3936

packages/node/src/executors/build/build.impl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import { ExecutorContext } from '@nrwl/devkit';
23

34
import { readCachedProjectGraph } from '@nrwl/workspace/src/core/project-graph';
@@ -18,10 +19,6 @@ import { BuildNodeBuilderOptions } from '../../utils/types';
1819
import { normalizeBuildOptions } from '../../utils/normalize';
1920
import { generatePackageJson } from '../../utils/generate-package-json';
2021

21-
try {
22-
require('dotenv').config();
23-
} catch (e) {}
24-
2522
export type NodeBuildEvent = {
2623
outfile: string;
2724
success: boolean;

packages/node/src/executors/execute/execute.impl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import {
23
runExecutor,
34
stripIndents,
@@ -14,10 +15,6 @@ import * as treeKill from 'tree-kill';
1415
import { NodeBuildEvent } from '../build/build.impl';
1516
import { BuildNodeBuilderOptions } from '../../utils/types';
1617

17-
try {
18-
require('dotenv').config();
19-
} catch (e) {}
20-
2118
export const enum InspectType {
2219
Inspect = 'inspect',
2320
InspectBrk = 'inspect-brk',

packages/nx-plugin/src/executors/e2e/e2e.impl.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import 'dotenv/config';
2+
13
import type { ExecutorContext } from '@nrwl/devkit';
4+
25
import {
36
convertNxExecutor,
47
logger,
@@ -9,11 +12,6 @@ import {
912
import { jestExecutor } from '@nrwl/jest/src/executors/jest/jest.impl';
1013
import type { NxPluginE2EExecutorOptions } from './schema';
1114

12-
try {
13-
require('dotenv').config();
14-
// eslint-disable-next-line no-empty
15-
} catch (e) {}
16-
1715
export async function* nxPluginE2EExecutor(
1816
options: NxPluginE2EExecutorOptions,
1917
context: ExecutorContext

packages/storybook/src/executors/build-storybook/build-storybook.impl.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dotenv/config';
12
import { basename, join, sep } from 'path';
23
import { tmpdir } from 'os';
34
import { constants, copyFileSync, mkdtempSync, statSync } from 'fs';
@@ -23,10 +24,6 @@ export interface StorybookBuilderOptions {
2324
docsMode?: boolean;
2425
}
2526

26-
try {
27-
require('dotenv').config();
28-
} catch (e) {}
29-
3027
export default async function buildStorybookExecutor(
3128
options: StorybookBuilderOptions,
3229
context: ExecutorContext

0 commit comments

Comments
 (0)