UNPKG

@nx/workspace

Version:

The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.

20 lines (19 loc) 666 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getImportPath = getImportPath; exports.getNpmScope = getNpmScope; const json_1 = require("nx/src/generators/utils/json"); function getImportPath(tree, projectDirectory) { const npmScope = getNpmScope(tree); return npmScope ? `${npmScope === '@' ? '' : '@'}${npmScope}/${projectDirectory}` : projectDirectory; } function getNpmScope(tree) { const { name } = tree.exists('package.json') ? (0, json_1.readJson)(tree, 'package.json') : { name: null }; if (name?.startsWith('@')) { return name.split('/')[0].substring(1); } }