Skip to content

Commit

Permalink
fix(core): generate proper cli command in lib readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell authored and FrozenPandaz committed Aug 18, 2020
1 parent 34e6c14 commit fdd9099
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Expand Up @@ -5,6 +5,6 @@ This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `ng test <%= name %>` to execute the unit tests via [Jest](https://jestjs.io).
Run `<%= cliCommand %> test <%= name %>` to execute the unit tests via [Jest](https://jestjs.io).

<% } %>
6 changes: 6 additions & 0 deletions packages/workspace/src/schematics/library/library.spec.ts
Expand Up @@ -2,6 +2,7 @@ import { Tree } from '@angular-devkit/schematics';
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
import { readJsonInTree, updateJsonInTree } from '@nrwl/workspace';
import { NxJson } from '@nrwl/workspace';

import { runSchematic } from '../../utils/testing';

describe('lib', () => {
Expand Down Expand Up @@ -98,9 +99,14 @@ describe('lib', () => {

it('should generate files', async () => {
const tree = await runSchematic('lib', { name: 'myLib' }, appTree);

expect(tree.exists(`libs/my-lib/jest.config.js`)).toBeTruthy();
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
expect(tree.exists('libs/my-lib/src/lib/my-lib.ts')).toBeTruthy();
expect(tree.exists('libs/my-lib/README.md')).toBeTruthy();

const ReadmeContent = tree.readContent('libs/my-lib/README.md');
expect(ReadmeContent).toContain('nx test my-lib');
});
});

Expand Down
2 changes: 2 additions & 0 deletions packages/workspace/src/schematics/library/library.ts
Expand Up @@ -21,6 +21,7 @@ import { formatFiles } from '@nrwl/workspace';
import { offsetFromRoot } from '@nrwl/workspace';
import { generateProjectLint, addLintFiles } from '../../utils/lint';
import { addProjectToNxJsonInTree, libsDir } from '../../utils/ast-utils';
import { cliCommand } from '../../core/file-utils';

export interface NormalizedSchema extends Schema {
name: string;
Expand Down Expand Up @@ -74,6 +75,7 @@ function createFiles(options: NormalizedSchema): Rule {
template({
...options,
...names(options.name),
cliCommand: cliCommand(),
tmpl: '',
offsetFromRoot: offsetFromRoot(options.projectRoot),
hasUnitTestRunner: options.unitTestRunner !== 'none',
Expand Down

0 comments on commit fdd9099

Please sign in to comment.