Skip to content

Commit

Permalink
feat(scoped): supports scoped packages, closes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Aug 17, 2016
1 parent 28231eb commit 0ee91ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
"test": "npm run rocha && grunt && npm run unit",
"unit": "gt src/test/*.js"
"unit": "gt src/test/*.js",
"lint": "grunt jshint"
}
}
11 changes: 10 additions & 1 deletion src/available.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ var _registryUrl = require('npm-utils').registryUrl;
la(check.fn(_registryUrl), 'expected registry url function');
var registryUrl = _.once(_registryUrl);

function scopeName(name) {
var slash = name.indexOf('/');
if (name[0] === '@' && slash !== -1) {
return name.substr(0, slash);
}
}

function formUrl(npmUrl, name) {
la(check.unemptyString(name), 'missing name string', name);

Expand Down Expand Up @@ -130,8 +137,10 @@ function fetchVersions(query, silent) {
};
}
la(check.object(query), 'expected {name, version}');
var scope = scopeName(query.name);
debug('fetching versions for scope', scope);
var queryFn = _.partial(queryRegistry, query, Boolean(silent));
return registryUrl()
return registryUrl(scope)
.then(queryFn);
}

Expand Down

0 comments on commit 0ee91ec

Please sign in to comment.