Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fdd9099

Browse files
HotellFrozenPandaz
authored andcommittedAug 18, 2020
fix(core): generate proper cli command in lib readme
1 parent 34e6c14 commit fdd9099

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed
 

‎packages/workspace/src/schematics/library/files/lib/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ This library was generated with [Nx](https://nx.dev).
55

66
## Running unit tests
77

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

1010
<% } %>

‎packages/workspace/src/schematics/library/library.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Tree } from '@angular-devkit/schematics';
22
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
33
import { readJsonInTree, updateJsonInTree } from '@nrwl/workspace';
44
import { NxJson } from '@nrwl/workspace';
5+
56
import { runSchematic } from '../../utils/testing';
67

78
describe('lib', () => {
@@ -98,9 +99,14 @@ describe('lib', () => {
9899

99100
it('should generate files', async () => {
100101
const tree = await runSchematic('lib', { name: 'myLib' }, appTree);
102+
101103
expect(tree.exists(`libs/my-lib/jest.config.js`)).toBeTruthy();
102104
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
103105
expect(tree.exists('libs/my-lib/src/lib/my-lib.ts')).toBeTruthy();
106+
expect(tree.exists('libs/my-lib/README.md')).toBeTruthy();
107+
108+
const ReadmeContent = tree.readContent('libs/my-lib/README.md');
109+
expect(ReadmeContent).toContain('nx test my-lib');
104110
});
105111
});
106112

‎packages/workspace/src/schematics/library/library.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { formatFiles } from '@nrwl/workspace';
2121
import { offsetFromRoot } from '@nrwl/workspace';
2222
import { generateProjectLint, addLintFiles } from '../../utils/lint';
2323
import { addProjectToNxJsonInTree, libsDir } from '../../utils/ast-utils';
24+
import { cliCommand } from '../../core/file-utils';
2425

2526
export interface NormalizedSchema extends Schema {
2627
name: string;
@@ -74,6 +75,7 @@ function createFiles(options: NormalizedSchema): Rule {
7475
template({
7576
...options,
7677
...names(options.name),
78+
cliCommand: cliCommand(),
7779
tmpl: '',
7880
offsetFromRoot: offsetFromRoot(options.projectRoot),
7981
hasUnitTestRunner: options.unitTestRunner !== 'none',

0 commit comments

Comments
 (0)
Please sign in to comment.