nx/packages/js/src/utils/get-import-path.ts
2023-05-15 16:06:24 -04:00

13 lines
374 B
TypeScript

import { Tree } from '@nx/devkit';
import { getNpmScope } from './package-json/get-npm-scope';
/**
* Prefixes project name with npm scope
*/
export function getImportPath(tree: Tree, projectDirectory: string): string {
const npmScope = getNpmScope(tree);
return npmScope
? `${npmScope === '@' ? '' : '@'}${npmScope}/${projectDirectory}`
: projectDirectory;
}