Skip to content

Commit

Permalink
fix: package name option name for 'application' schematics
Browse files Browse the repository at this point in the history
As the `application` schematics on `@nestjs/schematics` defines the name
`packageManager` to select the package manager to use, we could use pass
it directly from `nest new` command.
  • Loading branch information
micalevisk committed Oct 1, 2022
1 parent e8ddbf2 commit 2e6bd76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 4 additions & 7 deletions actions/new.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ const generateApplicationFiles = async (args: Input[], options: Input[]) => {
const mapSchematicOptions = (options: Input[]): SchematicOption[] => {
return options.reduce(
(schematicOptions: SchematicOption[], option: Input) => {
if (
option.name !== 'skip-install' &&
option.value !== 'package-manager'
) {
if (option.name !== 'skip-install') {
schematicOptions.push(new SchematicOption(option.name, option.value));
}
return schematicOptions;
Expand All @@ -138,7 +135,7 @@ const installPackages = async (
installDirectory: string,
) => {
const inputPackageManager: string = options.find(
(option) => option.name === 'package-manager',
(option) => option.name === 'packageManager',
)!.value as string;

let packageManager: AbstractPackageManager;
Expand Down Expand Up @@ -168,12 +165,12 @@ const installPackages = async (

const selectPackageManager = async (): Promise<AbstractPackageManager> => {
const answers: Answers = await askForPackageManager();
return PackageManagerFactory.create(answers['package-manager']);
return PackageManagerFactory.create(answers['packageManager']);
};

const askForPackageManager = async (): Promise<Answers> => {
const questions: Question[] = [
generateSelect('package-manager')(MESSAGES.PACKAGE_MANAGER_QUESTION)([
generateSelect('packageManager')(MESSAGES.PACKAGE_MANAGER_QUESTION)([
PackageManager.NPM,
PackageManager.YARN,
PackageManager.PNPM,
Expand Down
6 changes: 3 additions & 3 deletions commands/new.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export class NewCommand extends AbstractCommand {
.option('-g, --skip-git', 'Skip git repository initialization.', false)
.option('-s, --skip-install', 'Skip package installation.', false)
.option(
'-p, --package-manager [package-manager]',
'Specify package manager.'
'-p, --package-manager [packageManager]',
'Specify package manager.',
)
.option(
'-l, --language [language]',
Expand All @@ -41,7 +41,7 @@ export class NewCommand extends AbstractCommand {
options.push({ name: 'skip-install', value: command.skipInstall });
options.push({ name: 'strict', value: command.strict });
options.push({
name: 'package-manager',
name: 'packageManager',
value: command.packageManager,
});
options.push({ name: 'collection', value: command.collection });
Expand Down

0 comments on commit 2e6bd76

Please sign in to comment.