Skip to content

Commit

Permalink
Merge pull request #283 from Sikora00/feature/directory-option
Browse files Browse the repository at this point in the history
feat(): add directory option to the application schematic
  • Loading branch information
kamilmysliwiec committed Jan 13, 2020
2 parents 91df41d + 81ba857 commit 5f31c09
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/lib/application/application.factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,29 @@ describe('Application Factory', () => {
'/project/test/jest-e2e.json',
]);
});
it('should manage destination directory', () => {
const options: ApplicationOptions = {
name: '@scope/package',
directory: 'scope-package',
};
const tree: UnitTestTree = runner.runSchematic('application', options);
const files: string[] = tree.files;
expect(files).toEqual([
'/scope-package/.gitignore',
'/scope-package/.prettierrc',
'/scope-package/README.md',
'/scope-package/nest-cli.json',
'/scope-package/package.json',
'/scope-package/tsconfig.build.json',
'/scope-package/tsconfig.json',
'/scope-package/tslint.json',
'/scope-package/src/app.controller.spec.ts',
'/scope-package/src/app.controller.ts',
'/scope-package/src/app.module.ts',
'/scope-package/src/app.service.ts',
'/scope-package/src/main.ts',
'/scope-package/test/app.e2e-spec.ts',
'/scope-package/test/jest-e2e.json',
]);
});
});
2 changes: 1 addition & 1 deletion src/lib/application/application.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ApplicationOptions } from './application.schema';
export function main(options: ApplicationOptions): Rule {
options.name = strings.dasherize(options.name);

const path = options.name;
const path = options.directory || options.name;
options = transform(options);
return mergeWith(generate(options, path));
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/application/application.schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export interface ApplicationOptions {
* Nest application description.
*/
description?: string;
/**
* Nest application destination directory
*/
directory?: string;
/**
* Nest application version.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/lib/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"description": "Nest application description.",
"default": ""
},
"directory": {
"type": "string",
"description": "Nest application destination directory"
},
"version": {
"type": "string",
"description": "Nest application version.",
Expand Down

0 comments on commit 5f31c09

Please sign in to comment.