diff --git a/npm/ng-packs/packages/schematics/src/utils/index.ts b/npm/ng-packs/packages/schematics/src/utils/index.ts index f68cb11ded..cc9b0052fa 100644 --- a/npm/ng-packs/packages/schematics/src/utils/index.ts +++ b/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'; diff --git a/npm/ng-packs/packages/schematics/src/utils/path.ts b/npm/ng-packs/packages/schematics/src/utils/path.ts new file mode 100644 index 0000000000..a48534c92c --- /dev/null +++ b/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(/\/+$/, ''); +}