Files
meteor/tools/cordova/package-id-version-parser.js
Hugh Willson 27ed9bc2e8 Allow scoped Cordova packages to be installed
Fixes an issue preventing the installation of scoped Cordova
packages. For example,
`meteor add cordova:@somescope/some-cordova-plugin@1.0.0`
will now work properly.

Fixes https://github.com/meteor/meteor/issues/7336.
2017-11-17 01:58:54 +02:00

23 lines
666 B
JavaScript

// Accepts a combined Cordova package ID + version string, then parses out
// and returns the ID and version in a package details object.
//
// Example `packageIdAndVersion` formats:
// some-cordova-plugin@1.0.0
// @somescope/some-cordova-plugin@1.0.0
exports.parse = packageIdAndVersion => {
const packageDetails = {};
if (packageIdAndVersion) {
const [
_matchText,
scope,
packageName,
version,
] = packageIdAndVersion.match(
/^(?:@([^\/]+)\/)?([^\/@]+)@?(.+)?/
);
packageDetails.id = (scope ? `@${scope}/` : '') + packageName;
packageDetails.version = version ? version : null;
}
return packageDetails;
};