fix(angular): allow creating an app named 'app' or lib named 'lib'
Currently when trying to create an app named 'app' or a lib named 'lib', the schematics inject the 'projectType' as 'apps/application' or lib as 'libs/library', breaking the Angular build. fix #1844
This commit is contained in:
parent
607bcfdeb2
commit
f095647013
@ -140,6 +140,12 @@ describe('app', () => {
|
|||||||
expect(result.exists('apps/my-app/src/main.ts')).toEqual(true);
|
expect(result.exists('apps/my-app/src/main.ts')).toEqual(true);
|
||||||
expect(result.exists('apps/my-app-e2e/protractor.conf.js')).toEqual(true);
|
expect(result.exists('apps/my-app-e2e/protractor.conf.js')).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set projectType to application', async () => {
|
||||||
|
const tree = await runSchematic('app', { name: 'app' }, appTree);
|
||||||
|
const workspaceJson = readJsonInTree(tree, '/workspace.json');
|
||||||
|
expect(workspaceJson.projects['app'].projectType).toEqual('application');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('nested', () => {
|
describe('nested', () => {
|
||||||
|
|||||||
25
packages/workspace/src/utils/cli-config-utils.spec.ts
Normal file
25
packages/workspace/src/utils/cli-config-utils.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { replaceAppNameWithPath } from './cli-config-utils';
|
||||||
|
|
||||||
|
describe('replaceAppNameWithPath', () => {
|
||||||
|
describe('when node is `application`', () => {
|
||||||
|
describe('and appName is `app`', () => {
|
||||||
|
it('still returns the node', () => {
|
||||||
|
const node = 'application';
|
||||||
|
const appName = 'app';
|
||||||
|
const root = 'apps/app';
|
||||||
|
expect(replaceAppNameWithPath(node, appName, root)).toEqual(node);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when node is `library`', () => {
|
||||||
|
describe('and appName is `lib`', () => {
|
||||||
|
it('still returns the node', () => {
|
||||||
|
const node = 'library';
|
||||||
|
const appName = 'lib';
|
||||||
|
const root = 'libs/lib';
|
||||||
|
expect(replaceAppNameWithPath(node, appName, root)).toEqual(node);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -39,7 +39,11 @@ export function replaceAppNameWithPath(
|
|||||||
`([^a-z0-9]*(${appName}))|((${appName})[^a-z0-9:]*)`,
|
`([^a-z0-9]*(${appName}))|((${appName})[^a-z0-9:]*)`,
|
||||||
'gi'
|
'gi'
|
||||||
);
|
);
|
||||||
if (!!node.match(matchPattern)) {
|
if (
|
||||||
|
!!node.match(matchPattern) &&
|
||||||
|
node !== 'application' &&
|
||||||
|
node !== 'library'
|
||||||
|
) {
|
||||||
const r = node.replace(appName, root);
|
const r = node.replace(appName, root);
|
||||||
return r.startsWith('/apps') || r.startsWith('/libs')
|
return r.startsWith('/apps') || r.startsWith('/libs')
|
||||||
? r.substring(1)
|
? r.substring(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user