Git Product home page Git Product logo

get-latest-version's Introduction

get-latest-version

Find the latest version of an npm module matching a given semver range

npm versionBuild status

Installing

npm install --save get-latest-version

Basic usage

const getLatestVersion = require('get-latest-version')

getLatestVersion('some-module')
  .then((version) => console.log(version)) // 1.0.0, or whichever is 'latest'
  .catch((err) => console.error(err))

getLatestVersion('some-other-module', {range: '^1.0.0'})
  .then((version) => console.log(version)) // highest version matching ^1.0.0 range
  .catch((err) => console.error(err))

// Returns both the highest in the given range and the actual `latest` tag
// Note that this differens in that the return value is an object
getLatestVersion('@sanity/base', {range: '^1.0.0', includeLatest: true})
  .then((versions) => console.log(versions)) // {inRange: '1.150.8', latest '2.23.0'}
  .catch((err) => console.error(err))

Disabling authenticated requests

By default, this module will read the authorization token for whichever registry the module belongs to, based on local npm configuration. To disable this and always send unauthenticated requests to the registry, provide auth: false to the options:

getLatestVersion('some-module', {auth: false})
  .then((version) => console.log(version))
  .catch((err) => console.error(err))

Developing

git clone [email protected]:rexxars/get-latest-version.git
cd get-latest-version
npm install
npm test

License

MIT © Espen Hovlandsdal

get-latest-version's People

Contributors

rexxars avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.