Skip to content

Commit

Permalink
fix() add missing project option (nest g)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Sep 20, 2019
1 parent c33913e commit a694f28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 8 additions & 4 deletions actions/generate.action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import chalk from 'chalk';
import { Input } from '../commands';
import { getValueOrDefault } from '../lib/compiler/helpers/get-value-or-default';
import { Configuration, ConfigurationLoader } from '../lib/configuration';
import { NestConfigurationLoader } from '../lib/configuration/nest-configuration.loader';
import { FileSystemReader } from '../lib/readers';
Expand All @@ -20,18 +21,21 @@ const generateFiles = async (inputs: Input[]) => {
const configuration = await loadConfiguration();
const collectionOption = inputs.find(option => option.name === 'collection')!
.value as string;
const appName = inputs.find(option => option.name === 'project')!
.value as string;

const collection: AbstractCollection = CollectionFactory.create(
collectionOption || configuration.collection,
);
const schematicOptions: SchematicOption[] = mapSchematicOptions(inputs);

schematicOptions.push(
new SchematicOption('language', configuration.language),
);
schematicOptions.push(
new SchematicOption('sourceRoot', configuration.sourceRoot),
);

const sourceRoot = appName
? getValueOrDefault(configuration, 'sourceRoot', appName)
: configuration.sourceRoot;
schematicOptions.push(new SchematicOption('sourceRoot', sourceRoot));
try {
const schematicInput = inputs.find(input => input.name === 'schematic');
if (!schematicInput) {
Expand Down
5 changes: 5 additions & 0 deletions commands/generate.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class GenerateCommand extends AbstractCommand {
.alias('g')
.description(this.buildDescription())
.option('--dry-run', 'Allow to test changes before command execution')
.option('-p, --project [project]', 'Project in which to generate files')
.option('--flat', 'Enforce flat structure of generated element')
.option('--no-spec', 'Disable spec files generation')
.option(
Expand All @@ -36,6 +37,10 @@ export class GenerateCommand extends AbstractCommand {
name: 'collection',
value: command.collection || Collection.NESTJS,
});
options.push({
name: 'project',
value: command.project,
});

const inputs: Input[] = [];
inputs.push({ name: 'schematic', value: schematic });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/cli",
"version": "6.8.0",
"version": "6.8.1",
"description": "Nest - modern, fast, powerful node.js web framework (@cli)",
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit a694f28

Please sign in to comment.