Skip to content

Commit

Permalink
fix(core): handle npm package deletion and whole file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo authored and vsavkin committed Mar 10, 2020
1 parent 235e6e4 commit aa738fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('getTouchedNpmPackages', () => {
}
}
);
expect(result).toEqual(['happy-nrwl']);
expect(result).toEqual(['proj1', 'proj2']);
});

it('should handle whole file changes', () => {
Expand All @@ -109,6 +109,6 @@ describe('getTouchedNpmPackages', () => {
}
}
);
expect(result).toEqual(['proj1', 'proj2']);
expect(result).toEqual(['happy-nrwl', 'awesome-nrwl']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ export const getTouchedNpmPackages: TouchedProjectLocator<
isJsonChange(c) &&
(c.path[0] === 'dependencies' || c.path[0] === 'devDependencies')
) {
// A package was deleted so mark all packages as touched
// so projects with any package dependency will be affected.
// A package was deleted so mark all workspace projects as touched.
if (c.type === DiffType.Deleted) {
touched = Object.keys({
...(packageJson.dependencies || {}),
...(packageJson.devDependencies || {})
});
touched = Object.keys(workspaceJson.projects);
break;
} else {
touched.push(c.path[1]);
}
} else if (isWholeFileChange(c)) {
touched = Object.keys(workspaceJson.projects);
// Whole file was touched, so all npm packages are touched.
touched = Object.keys({
...(packageJson.dependencies || {}),
...(packageJson.devDependencies || {})
});
break;
}
}
Expand Down

0 comments on commit aa738fa

Please sign in to comment.