Skip to content

Commit

Permalink
chore(core): address pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Jun 21, 2023
1 parent e577641 commit e0a6496
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
9 changes: 9 additions & 0 deletions e2e/nx-run/src/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ describe('Nx Running Tests', () => {
scripts: {
[target]: `echo ${expectedOutput}`,
},
nx: {
targets: {
[target]: {
configurations: {
production: {},
},
},
},
},
})
);

Expand Down
28 changes: 4 additions & 24 deletions packages/nx/src/utils/project-graph-utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { buildTargetFromScript, PackageJson } from './package-json';
import { join } from 'path';
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
import { fileExists, readJsonFile } from './fileutils';
import { readJsonFile } from './fileutils';
import { readCachedProjectGraph } from '../project-graph/project-graph';
import { TargetConfiguration } from '../config/workspace-json-project-json';
import { workspaceRoot } from './workspace-root';

export function projectHasTarget(
project: ProjectGraphProjectNode,
Expand All @@ -23,28 +22,9 @@ export function projectHasTargetAndConfiguration(
configuration: string
) {
return (
// Explicitly defined target + configuration
(projectHasTarget(project, target) &&
project.data.targets[target].configurations &&
project.data.targets[target].configurations[configuration]) ||
// Inferred configuration from presence of .env files
(projectHasTarget(project, target) &&
[
join(workspaceRoot, `.env.${configuration}`),
join(workspaceRoot, `.${configuration}.env`),
join(workspaceRoot, project.data.root, `.env.${configuration}`),
join(workspaceRoot, project.data.root, `.${configuration}.env`),
join(
workspaceRoot,
project.data.root,
`.env.${target}.${configuration}`
),
join(
workspaceRoot,
project.data.root,
`.${target}.${configuration}.env`
),
].some(fileExists))
projectHasTarget(project, target) &&
project.data.targets[target].configurations &&
project.data.targets[target].configurations[configuration]
);
}

Expand Down

0 comments on commit e0a6496

Please sign in to comment.