Skip to content

Commit 8003766

Browse files
committed
fix(core): fix affected detection for inputs after named inputs (#23354)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> Inputs after named inputs are not considered for affected. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Inputs after named inputs are considered for affected... ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # (cherry picked from commit 722b2d0)
1 parent 508e87f commit 8003766

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/nx/src/project-graph/affected/locators/workspace-projects.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('getImplicitlyTouchedProjects', () => {
139139
root: 'a',
140140
targets: {
141141
build: {
142-
inputs: ['files'],
142+
inputs: ['files', '{workspaceRoot}/b.txt'],
143143
},
144144
},
145145
},
@@ -151,6 +151,10 @@ describe('getImplicitlyTouchedProjects', () => {
151151
expect(getImplicitlyTouchedProjects(fileChanges, graph, nxJson)).toEqual([
152152
'a',
153153
]);
154+
fileChanges = getFileChanges(['b.txt']);
155+
expect(getImplicitlyTouchedProjects(fileChanges, graph, nxJson)).toEqual([
156+
'a',
157+
]);
154158
});
155159

156160
it('should not return projects which have touched files inputs which are not used by its targets', () => {

packages/nx/src/project-graph/affected/locators/workspace-projects.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ function extractFilesFromInputs(
8989
const globalFiles = [];
9090
for (const input of inputs) {
9191
if (typeof input === 'string' && input in namedInputs) {
92-
return extractFilesFromInputs(namedInputs[input], namedInputs);
92+
globalFiles.push(
93+
...extractFilesFromInputs(namedInputs[input], namedInputs)
94+
);
9395
} else if (
9496
typeof input === 'string' &&
9597
input.startsWith('{workspaceRoot}/')

0 commit comments

Comments
 (0)