Skip to content

Commit

Permalink
Only replace last @ after (if any) last / with # (#2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
doomedramen authored and sheerun committed Mar 28, 2018
1 parent a6308bf commit 74af42c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
45 changes: 24 additions & 21 deletions lib/commands/info.js
Expand Up @@ -10,7 +10,10 @@ function info(logger, endpoint, property, config) {
}

// handle @ as version divider
endpoint = endpoint.replace('@', '#');
var splitParts = endpoint.split('/');
splitParts[splitParts.length - 1] = splitParts[splitParts.length - 1].replace('@', '#');
endpoint = splitParts.join('/');


var repository;
var decEndpoint;
Expand All @@ -24,33 +27,33 @@ function info(logger, endpoint, property, config) {
getPkgMeta(repository, decEndpoint, property),
decEndpoint.target === '*' && !property ? repository.versions(decEndpoint.source) : null
])
.spread(function (pkgMeta, versions) {
if (versions) {
return {
name: decEndpoint.source,
versions: versions,
latest: pkgMeta
};
}
.spread(function (pkgMeta, versions) {
if (versions) {
return {
name: decEndpoint.source,
versions: versions,
latest: pkgMeta
};
}

return pkgMeta;
});
return pkgMeta;
});
}

function getPkgMeta(repository, decEndpoint, property) {
return repository.fetch(decEndpoint)
.spread(function (canonicalDir, pkgMeta) {
pkgMeta = mout.object.filter(pkgMeta, function (value, key) {
return key.charAt(0) !== '_';
});
.spread(function (canonicalDir, pkgMeta) {
pkgMeta = mout.object.filter(pkgMeta, function (value, key) {
return key.charAt(0) !== '_';
});

// Retrieve specific property
if (property) {
pkgMeta = mout.object.get(pkgMeta, property);
}
// Retrieve specific property
if (property) {
pkgMeta = mout.object.get(pkgMeta, property);
}

return pkgMeta;
});
return pkgMeta;
});
}

// -------------------
Expand Down
16 changes: 10 additions & 6 deletions lib/commands/install.js
Expand Up @@ -16,8 +16,12 @@ function install(logger, endpoints, options, config) {
// Convert endpoints to decomposed endpoints
endpoints = endpoints || [];
decEndpoints = endpoints.map(function (endpoint) {

// handle @ as version divider
endpoint = endpoint.replace('@', '#');
var splitParts = endpoint.split('/');
splitParts[splitParts.length - 1] = splitParts[splitParts.length - 1].replace('@', '#');
endpoint = splitParts.join('/');

return endpointParser.decompose(endpoint);
});

Expand All @@ -30,11 +34,11 @@ install.readOptions = function (argv) {
var cli = require('../util/cli');

var options = cli.readOptions({
'force-latest': { type: Boolean, shorthand: 'F'},
'production': { type: Boolean, shorthand: 'p' },
'save': { type: Boolean, shorthand: 'S' },
'save-dev': { type: Boolean, shorthand: 'D' },
'save-exact': { type: Boolean, shorthand: 'E' }
'force-latest': {type: Boolean, shorthand: 'F'},
'production': {type: Boolean, shorthand: 'p'},
'save': {type: Boolean, shorthand: 'S'},
'save-dev': {type: Boolean, shorthand: 'D'},
'save-exact': {type: Boolean, shorthand: 'E'}
}, argv);

var packages = options.argv.remain.slice(1);
Expand Down

0 comments on commit 74af42c

Please sign in to comment.