Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa738fa

Browse files
jaysoovsavkin
authored andcommittedMar 10, 2020
fix(core): handle npm package deletion and whole file changes
1 parent 235e6e4 commit aa738fa

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
 

‎packages/workspace/src/core/affected-project-graph/locators/npm-packages.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('getTouchedNpmPackages', () => {
8787
}
8888
}
8989
);
90-
expect(result).toEqual(['happy-nrwl']);
90+
expect(result).toEqual(['proj1', 'proj2']);
9191
});
9292

9393
it('should handle whole file changes', () => {
@@ -109,6 +109,6 @@ describe('getTouchedNpmPackages', () => {
109109
}
110110
}
111111
);
112-
expect(result).toEqual(['proj1', 'proj2']);
112+
expect(result).toEqual(['happy-nrwl', 'awesome-nrwl']);
113113
});
114114
});

‎packages/workspace/src/core/affected-project-graph/locators/npm-packages.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ export const getTouchedNpmPackages: TouchedProjectLocator<
1616
isJsonChange(c) &&
1717
(c.path[0] === 'dependencies' || c.path[0] === 'devDependencies')
1818
) {
19-
// A package was deleted so mark all packages as touched
20-
// so projects with any package dependency will be affected.
19+
// A package was deleted so mark all workspace projects as touched.
2120
if (c.type === DiffType.Deleted) {
22-
touched = Object.keys({
23-
...(packageJson.dependencies || {}),
24-
...(packageJson.devDependencies || {})
25-
});
21+
touched = Object.keys(workspaceJson.projects);
2622
break;
2723
} else {
2824
touched.push(c.path[1]);
2925
}
3026
} else if (isWholeFileChange(c)) {
31-
touched = Object.keys(workspaceJson.projects);
27+
// Whole file was touched, so all npm packages are touched.
28+
touched = Object.keys({
29+
...(packageJson.dependencies || {}),
30+
...(packageJson.devDependencies || {})
31+
});
3232
break;
3333
}
3434
}

0 commit comments

Comments
 (0)
Please sign in to comment.