mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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.
23 lines
666 B
JavaScript
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;
|
|
};
|