Last active
April 21, 2025 23:51
-
-
Save BananaAcid/5b4fe0006d463f819c5fbd9b286cc323 to your computer and use it in GitHub Desktop.
simple version check on npm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import package from './package.json' with { type: "json" }; | |
let version = await fetch(`https://registry.npmjs.com/${package.name}/latest`).catch(_=>undefined).then(d => d?.json?.()).then(({version})=>version).catch(_=>undefined); | |
console.log(`Newest version is ${ version ?? 'unknown' }`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment