Skip to content

Commit

Permalink
fix(@schematics/angular): only remove tslib from package.json when …
Browse files Browse the repository at this point in the history
…it's not a dependency

Fixes: #16191
(cherry picked from commit e9551f9)
  • Loading branch information
alan-agius4 authored and dgp1130 committed Nov 14, 2019
1 parent ba58b13 commit c35f580
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/schematics/angular/migrations/update-9/add-tslib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
* found in the LICENSE file at https://angular.io/license
*/
import { Rule } from '@angular-devkit/schematics';
import { NodeDependencyType, addPackageJsonDependency, removePackageJsonDependency } from '../../utility/dependencies';
import { NodeDependencyType, addPackageJsonDependency, getPackageJsonDependency, removePackageJsonDependency } from '../../utility/dependencies';
import { latestVersions } from '../../utility/latest-versions';

export function addTsLib(): Rule {
return host => {
removePackageJsonDependency(host, 'tslib');
const tslibDep = getPackageJsonDependency(host, 'tslib');

if (tslibDep && tslibDep.type !== NodeDependencyType.Default) {
removePackageJsonDependency(host, 'tslib');
}

addPackageJsonDependency(host, {
name: 'tslib',
version: latestVersions.TsLib,
type: NodeDependencyType.Default,
name: 'tslib',
version: latestVersions.TsLib,
type: NodeDependencyType.Default,
overwrite: true,
});
};
}

0 comments on commit c35f580

Please sign in to comment.