fix(core): generate proper cli command in lib readme
This commit is contained in:
parent
91f4f60328
commit
a3fc7e18c0
@ -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).
|
||||
|
||||
<% } %>
|
||||
|
||||
@ -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', () => {
|
||||
@ -103,9 +104,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');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -22,6 +22,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;
|
||||
@ -80,6 +81,7 @@ function createFiles(options: NormalizedSchema): Rule {
|
||||
template({
|
||||
...options,
|
||||
...names(options.name),
|
||||
cliCommand: cliCommand(),
|
||||
tmpl: '',
|
||||
offsetFromRoot: offsetFromRoot(options.projectRoot),
|
||||
hasUnitTestRunner: options.unitTestRunner !== 'none',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user