Socket
Socket
Sign inDemoInstall

get-latest-version

Package Overview
Dependencies
32
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.1 to 5.1.0

2

package.json
{
"name": "get-latest-version",
"version": "5.0.1",
"version": "5.1.0",
"description": "Find the latest version of an npm module matching a given semver range",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -43,2 +43,13 @@ # get-latest-version

## Using custom registry
By default, module utilizes [registry-url](https://www.npmjs.com/package/registry-url) to resolve registry URL from NPM configuration files. However, if you need to set up the registry programmatically, you can make use of the `registryUrl` option:
```js
getLatestVersion('some-module', {registryUrl: 'https://some-custom-registry.com'})
.then((version) => console.log(version))
.catch((err) => console.error(err))
```
## Developing

@@ -45,0 +56,0 @@

@@ -5,2 +5,3 @@ declare namespace getLatestVersion {

readonly range?: string
readonly registryUrl?: string
}

@@ -7,0 +8,0 @@ interface WithLatestOptions extends BaseOptions {

@@ -23,2 +23,10 @@ const url = require('url')

function resolveRegistryUrl(pkgName, options) {
if (options.registryUrl) {
return options.registryUrl
}
const scope = pkgName.split('/')[0]
return registryUrl(scope);
}
const httpRequest = getIt([

@@ -33,5 +41,2 @@ jsonResponse({force: true}),

async function getLatestVersion(pkgName, opts) {
const scope = pkgName.split('/')[0]
const regUrl = registryUrl(scope)
const pkgUrl = url.resolve(regUrl, encodeURIComponent(pkgName).replace(/^%40/, '@'))
const options =

@@ -42,2 +47,4 @@ typeof opts === 'string'

const regUrl = resolveRegistryUrl(pkgName, options)
const pkgUrl = url.resolve(regUrl, encodeURIComponent(pkgName).replace(/^%40/, '@'))
const authInfo = options.auth && registryAuthToken(regUrl, {recursive: true})

@@ -44,0 +51,0 @@ const request = options.request || httpRequest

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc