UNPKG

@nx/devkit

Version:

The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by

18 lines (17 loc) 637 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkAndCleanWithSemver = checkAndCleanWithSemver; const semver_1 = require("semver"); function checkAndCleanWithSemver(pkgName, version) { let newVersion = version; if ((0, semver_1.valid)(newVersion)) { return newVersion; } if (version.startsWith('~') || version.startsWith('^')) { newVersion = version.substring(1); } if (!(0, semver_1.valid)(newVersion)) { throw new Error(`The package.json lists a version of ${pkgName} that Nx is unable to validate - (${version})`); } return newVersion; }