Browse Source

feat: add parseNamespace utility fn to schematics

pull/5137/head
Arman Ozak 6 years ago
parent
commit
3cc935918d
  1. 1
      npm/ng-packs/packages/schematics/src/utils/index.ts
  2. 15
      npm/ng-packs/packages/schematics/src/utils/namespace.ts

1
npm/ng-packs/packages/schematics/src/utils/index.ts

@ -1,6 +1,7 @@
export * from './angular';
export * from './ast';
export * from './common';
export * from './namespace';
export * from './rule';
export * from './source';
export * from './text';

15
npm/ng-packs/packages/schematics/src/utils/namespace.ts

@ -0,0 +1,15 @@
export function parseNamespace(solution: string, type: string) {
let namespace = type
.split('.')
.slice(0, -1)
.join('.');
solution.split('.').reduceRight((acc, part) => {
acc = part + '.' + acc;
const regex = new RegExp('^' + acc + '(Controllers.)?');
namespace = namespace.replace(regex, '');
return acc;
}, '');
return namespace;
}
Loading…
Cancel
Save