mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-05 12:41:44 -05:00
27 lines
771 B
JavaScript
27 lines
771 B
JavaScript
var resolveNpm = require('./resolve/npm')
|
|
var resolveTarball = require('./resolve/tarball')
|
|
|
|
/**
|
|
* Resolves a package in the NPM registry. Done as part of `install()`.
|
|
*
|
|
* var npa = require('npm-package-arg')
|
|
* resolve(npa('rimraf@2'))
|
|
* .then((res) => {
|
|
* res.fullname == 'rimraf@2.5.1'
|
|
* res.dist == {
|
|
* shasum: '0a1b2c...'
|
|
* tarball: 'http://...'
|
|
* }
|
|
* })
|
|
*/
|
|
|
|
module.exports = function resolve (pkg, log) {
|
|
if (pkg.type === 'range' || pkg.type === 'version' || pkg.type === 'tag') {
|
|
return resolveNpm(pkg, log)
|
|
} else if (pkg.type === 'remote') {
|
|
return resolveTarball(pkg, log)
|
|
} else {
|
|
throw new Error('' + pkg.rawSpec + ': ' + pkg.type + ' packages not supported')
|
|
}
|
|
}
|