Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only replace last @ after (if any) last / with # #2395

Merged
merged 2 commits into from Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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