Browse Source

feat: add relativePathFromServiceToModel utility fn

pull/5137/head
Arman Ozak 6 years ago
parent
commit
ab710827d6
  1. 1
      npm/ng-packs/packages/schematics/src/utils/index.ts
  2. 11
      npm/ng-packs/packages/schematics/src/utils/path.ts

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

@ -2,6 +2,7 @@ export * from './angular';
export * from './ast';
export * from './common';
export * from './namespace';
export * from './path';
export * from './rule';
export * from './service';
export * from './source';

11
npm/ng-packs/packages/schematics/src/utils/path.ts

@ -0,0 +1,11 @@
import { dir } from './text';
export function relativePathFromServiceToModel(serviceNamespace: string, modelNamespace: string) {
const repeats = serviceNamespace ? serviceNamespace.split('.').length : 0;
const path = '..' + '/..'.repeat(repeats) + '/models/' + dir(modelNamespace);
return removeTrailingSlash(path);
}
function removeTrailingSlash(path: string) {
return path.replace(/\/+$/, '');
}
Loading…
Cancel
Save