MCPcopy Index your code
hub / github.com/angular/angular-cli / replaceDependencies

Function replaceDependencies

tests/e2e/utils/project.ts:97–124  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

95 return updateJsonFile('package.json', (json) => {
96 // Install over the project with snapshot builds.
97 function replaceDependencies(key: string) {
98 const missingSnapshots: string[] = [];
99 Object.keys(json[key] || {})
100 .filter((name) => name.startsWith('@angular/'))
101 .forEach((name) => {
102 const pkgName = name.split(/\//)[1];
103 if (pkgName === 'cli' || pkgName === 'ssr' || pkgName === 'build') {
104 return;
105 }
106
107 if (label) {
108 json[key][`@angular/${pkgName}`] = `github:angular/${pkgName}-builds${label}`;
109 } else {
110 const replacement = ngSnapshotVersions.dependencies[`@angular/${pkgName}`];
111 if (!replacement) {
112 missingSnapshots.push(`missing @angular/${pkgName}`);
113 }
114 json[key][`@angular/${pkgName}`] = replacement;
115 }
116 });
117 if (missingSnapshots.length > 0) {
118 throw new Error(
119 'e2e test with --ng-snapshots requires all angular packages be ' +
120 'listed in tests/e2e/ng-snapshot/package.json.\nErrors:\n' +
121 missingSnapshots.join('\n '),
122 );
123 }
124 }
125
126 replaceDependencies('dependencies');
127 replaceDependencies('devDependencies');

Callers 1

useShaFunction · 0.85

Calls 3

forEachMethod · 0.45
keysMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected