UNPKG

@nx/js

Version:

The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects.

29 lines (28 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveVersionSpec = resolveVersionSpec; const npa = require("npm-package-arg"); const devkit_1 = require("@nx/devkit"); function resolveVersionSpec(name, version, spec, location) { // yarn classic uses link instead of file, normalize to match what npm expects spec = spec.replace(/^link:/, 'file:'); // Support workspace: protocol for pnpm and yarn 2+ (https://pnpm.io/workspaces#workspace-protocol-workspace) const isWorkspaceSpec = /^workspace:/.test(spec); if (isWorkspaceSpec) { spec = spec.replace(/^workspace:/, ''); // replace aliases (https://pnpm.io/workspaces#referencing-workspace-packages-through-aliases) if (spec === '*' || spec === '^' || spec === '~') { if (version) { const prefix = spec === '*' ? '' : spec; spec = `${prefix}${version}`; } else { spec = '*'; } } } const npaResult = npa.resolve(name, spec, location); return npaResult.fetchSpec.includes('\\') ? (0, devkit_1.normalizePath)(npaResult.fetchSpec) : npaResult.fetchSpec; }