A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/angular/angular-cli/commit/b8bf3b480bef752641370e542ebb5aee649a8ac6 below:

only issue a warning for addDependency exis… · angular/angular-cli@b8bf3b4 · GitHub

@@ -17,17 +17,31 @@ import {

17 17

} from '@angular-devkit/schematics';

18 18

import { DependencyType, InstallBehavior, addDependency } from './dependency';

19 19 20 -

async function testRule(rule: Rule, tree: Tree): Promise<TaskConfigurationGenerator[]> {

20 +

interface LogEntry {

21 +

type: 'warn';

22 +

message: string;

23 +

}

24 + 25 +

async function testRule(

26 +

rule: Rule,

27 +

tree: Tree,

28 +

): Promise<{ tasks: TaskConfigurationGenerator[]; logs: LogEntry[] }> {

21 29

const tasks: TaskConfigurationGenerator[] = [];

30 +

const logs: LogEntry[] = [];

22 31

const context = {

23 32

addTask(task: TaskConfigurationGenerator) {

24 33

tasks.push(task);

25 34

},

35 +

logger: {

36 +

warn(message: string): void {

37 +

logs.push({ type: 'warn', message });

38 +

},

39 +

},

26 40

};

27 41 28 42

await callRule(rule, tree, context as unknown as SchematicContext).toPromise();

29 43 30 -

return tasks;

44 +

return { tasks, logs };

31 45

}

32 46 33 47

describe('addDependency', () => {

@@ -49,7 +63,7 @@ describe('addDependency', () => {

49 63

});

50 64

});

51 65 52 -

it('throws if a package is already present with a different specifier', async () => {

66 +

it('warns if a package is already present with a different specifier', async () => {

53 67

const tree = new EmptyTree();

54 68

tree.create(

55 69

'/package.json',

@@ -60,9 +74,14 @@ describe('addDependency', () => {

60 74 61 75

const rule = addDependency('@angular/core', '^14.0.0');

62 76 63 -

await expectAsync(testRule(rule, tree)).toBeRejectedWithError(

64 -

undefined,

65 -

'Package dependency "@angular/core" already exists with a different specifier.',

77 +

const { logs } = await testRule(rule, tree);

78 +

expect(logs).toContain(

79 +

jasmine.objectContaining({

80 +

type: 'warn',

81 +

message:

82 +

'Package dependency "@angular/core" already exists with a different specifier. ' +

83 +

'"^13.0.0" will be replaced with "^14.0.0".',

84 +

}),

66 85

);

67 86

});

68 87

@@ -164,7 +183,7 @@ describe('addDependency', () => {

164 183 165 184

const rule = addDependency('@angular/core', '^14.0.0');

166 185 167 -

const tasks = await testRule(rule, tree);

186 +

const { tasks } = await testRule(rule, tree);

168 187 169 188

expect(tasks.map((task) => task.toConfiguration())).toEqual([

170 189

{

@@ -182,7 +201,7 @@ describe('addDependency', () => {

182 201

packageJsonPath: '/abc/package.json',

183 202

});

184 203 185 -

const tasks = await testRule(rule, tree);

204 +

const { tasks } = await testRule(rule, tree);

186 205 187 206

expect(tasks.map((task) => task.toConfiguration())).toEqual([

188 207

{

@@ -201,7 +220,7 @@ describe('addDependency', () => {

201 220

install: InstallBehavior.Auto,

202 221

});

203 222 204 -

const tasks = await testRule(rule, tree);

223 +

const { tasks } = await testRule(rule, tree);

205 224 206 225

expect(tasks.map((task) => task.toConfiguration())).toEqual([

207 226

{

@@ -220,7 +239,7 @@ describe('addDependency', () => {

220 239

install: InstallBehavior.Always,

221 240

});

222 241 223 -

const tasks = await testRule(rule, tree);

242 +

const { tasks } = await testRule(rule, tree);

224 243 225 244

expect(tasks.map((task) => task.toConfiguration())).toEqual([

226 245

{

@@ -239,7 +258,7 @@ describe('addDependency', () => {

239 258

install: InstallBehavior.None,

240 259

});

241 260 242 -

const tasks = await testRule(rule, tree);

261 +

const { tasks } = await testRule(rule, tree);

243 262 244 263

expect(tasks).toEqual([]);

245 264

});

@@ -255,7 +274,7 @@ describe('addDependency', () => {

255 274 256 275

const rule = addDependency('@angular/core', '^14.0.0');

257 276 258 -

const tasks = await testRule(rule, tree);

277 +

const { tasks } = await testRule(rule, tree);

259 278 260 279

expect(tasks).toEqual([]);

261 280

});

@@ -269,7 +288,7 @@ describe('addDependency', () => {

269 288

addDependency('@angular/common', '^14.0.0'),

270 289

]);

271 290 272 -

const tasks = await testRule(rule, tree);

291 +

const { tasks } = await testRule(rule, tree);

273 292 274 293

expect(tasks.map((task) => task.toConfiguration())).toEqual([

275 294

{

@@ -288,7 +307,7 @@ describe('addDependency', () => {

288 307

addDependency('@angular/common', '^14.0.0', { install: InstallBehavior.Auto }),

289 308

]);

290 309 291 -

const tasks = await testRule(rule, tree);

310 +

const { tasks } = await testRule(rule, tree);

292 311 293 312

expect(tasks.map((task) => task.toConfiguration())).toEqual([

294 313

{

@@ -307,7 +326,7 @@ describe('addDependency', () => {

307 326

addDependency('@angular/common', '^14.0.0', { install: InstallBehavior.None }),

308 327

]);

309 328 310 -

const tasks = await testRule(rule, tree);

329 +

const { tasks } = await testRule(rule, tree);

311 330 312 331

expect(tasks.map((task) => task.toConfiguration())).toEqual([

313 332

{

@@ -326,7 +345,7 @@ describe('addDependency', () => {

326 345

addDependency('@angular/common', '^14.0.0', { install: InstallBehavior.Auto }),

327 346

]);

328 347 329 -

const tasks = await testRule(rule, tree);

348 +

const { tasks } = await testRule(rule, tree);

330 349 331 350

expect(tasks.map((task) => task.toConfiguration())).toEqual([

332 351

{

@@ -345,7 +364,7 @@ describe('addDependency', () => {

345 364

addDependency('@angular/common', '^14.0.0', { install: InstallBehavior.Always }),

346 365

]);

347 366 348 -

const tasks = await testRule(rule, tree);

367 +

const { tasks } = await testRule(rule, tree);

349 368 350 369

expect(tasks.map((task) => task.toConfiguration())).toEqual([

351 370

{

@@ -369,7 +388,7 @@ describe('addDependency', () => {

369 388

addDependency('@angular/common', '^14.0.0', { packageJsonPath: '/abc/package.json' }),

370 389

]);

371 390 372 -

const tasks = await testRule(rule, tree);

391 +

const { tasks } = await testRule(rule, tree);

373 392 374 393

expect(tasks.map((task) => task.toConfiguration())).toEqual([

375 394

{


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4