feat(@angular-devkit/schematics-cli): auto detect package manager by MarvinXu · Pull Request #24305 · angular/angular-cli

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Can't specify packageManager when running a schematic

Issue Number: N/A

What is the new behavior?

Detect packageManager by the lock file, and use the right package manager to install dependencies. Behave like ng generate <schematic>

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This PR originates from nestjs/nest-cli#1115

As I look into the problem, first I wanted to fix it in @nestjs/schematics

but then I checked Angular cli, and run the following command, it worked as excepted(using correct package manager).

ng new test --no-install
cd test
touch yarn.lock
ng g @nestjs/schematics:resource --name=users --no-dry-run --no-skip-import --language="ts" --source-root="src" --spec --no-flat

So I thought maybe it's better to fix it in schematics-cli to make it behave just like angular-cli.

I am a new contributor, plz let me know If I did anything wrong ;)