Skip to content

Commit

Permalink
chore(core): fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Jan 28, 2024
1 parent 7901c3b commit 48164bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
13 changes: 11 additions & 2 deletions packages/nx/src/generators/utils/project-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ function readAndCombineAllProjectConfigurations(tree: Tree): {
if (basename(projectFile) === 'project.json') {
const json = readJson(tree, projectFile);
const config = buildProjectFromProjectJson(json, projectFile);
mergeProjectConfigurationIntoRootMap(rootMap, config);
mergeProjectConfigurationIntoRootMap(
rootMap,
config,
undefined,
undefined,
true
);
} else if (basename(projectFile) === 'package.json') {
const packageJson = readJson<PackageJson>(tree, projectFile);
const config = buildProjectConfigurationFromPackageJson(
Expand All @@ -227,7 +233,10 @@ function readAndCombineAllProjectConfigurations(tree: Tree): {
{
name: config.name,
root: config.root,
}
},
undefined,
undefined,
true
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,6 @@ describe('workspace-projects', () => {
});

describe('normalizeTargets', () => {
it('should convert command property to run-commands executor', () => {
expect(
normalizeProjectTargets(
{
root: 'my/project',
targets: {
build: {
command: 'echo',
},
},
},
'build'
).build
).toEqual({
executor: 'nx:run-commands',
configurations: {},
options: {
command: 'echo',
},
});
});

it('should support {projectRoot}, {workspaceRoot}, and {projectName} tokens', () => {
expect(
normalizeProjectTargets(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ describe('project-configuration-utils', () => {
"root": "libs/lib-a",
"targets": {
"build": {
"command": "tsc",
"executor": "nx:run-commands",
"options": {
"command": "tsc",
},
},
"echo": {
"command": "echo lib-a",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export function mergeProjectConfigurationIntoRootMap(
>;
},
configurationSourceMaps?: ConfigurationSourceMaps,
sourceInformation?: SourceInformation
sourceInformation?: SourceInformation,
// This function is used when reading project configuration
// in generators, where we don't want to do this.
skipCommandNormalization?: boolean
): void {
if (configurationSourceMaps && !configurationSourceMaps[project.root]) {
configurationSourceMaps[project.root] = {};
Expand Down Expand Up @@ -158,11 +161,13 @@ export function mergeProjectConfigurationIntoRootMap(

updatedProjectConfiguration.targets[targetName] =
mergeTargetConfigurations(
resolveCommandSyntacticSugar(target, project.root),
skipCommandNormalization
? target
: resolveCommandSyntacticSugar(target, project.root),
matchingProject.targets?.[targetName],
sourceMap,
sourceInformation,
`targets.${target}`
`targets.${targetName}`
);
}
}
Expand Down

0 comments on commit 48164bd

Please sign in to comment.