Getting NPM package version and URL
This tutorial is part of package functions documentation in Iconify Tools.
Function getNPMVersion() retrieves latest version of package from NPM registry and URL to download package.
Usage
Function has the following parameter:
- options, NPMPackageOptions. Options, same as in downloadNPMPackage() function (only package and tag properties are used).
Function returns object with the following properties:
- version, string. Version number.
- file, string. URL of archive, if available.
Example
example.ts
ts
import { getNPMVersion } from '@iconify/tools';
(async () => {
console.log(
await getNPMVersion({
package: '@iconify-json/mdi-light',
// tag: 'latest',
})
);
})();
Result:
json
{
"version": "1.0.1",
"file": "https://registry.npmjs.org/@iconify-json/mdi-light/-/mdi-light-1.0.1.tgz"
}