-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): don't use beta tag (#599)
* fix(docs): don't use beta tag * chore: update GHA copy * chore: smol cleanups
- Loading branch information
1 parent
7bd081a
commit 12d709b
Showing
6 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
import pkg from '../../package.json'; | ||
|
||
const registryUrl = 'https://registry.npmjs.com/rdme'; | ||
|
||
/** | ||
* The current `rdme` version | ||
* | ||
* @param npmDistTag the `npm` dist tag to retrieve. If this value is omitted, | ||
* the version from the `package.json` is returned. | ||
* @example "8.0.0" | ||
* @see {@link https://docs.npmjs.com/cli/dist-tag} | ||
* @note we mock this function in our snapshots | ||
* @see {@link https://stackoverflow.com/a/54245672} | ||
*/ | ||
export async function getPkgVersion(npmDistTag?: 'latest' | 'next'): Promise<string> { | ||
if (npmDistTag) { | ||
return fetch(registryUrl) | ||
.then(res => res.json()) | ||
.then(body => body['dist-tags'][npmDistTag]) | ||
.catch(() => { | ||
// eslint-disable-next-line no-console | ||
console.error('error fetching version from npm registry'); | ||
return pkg.version; | ||
}); | ||
} | ||
return pkg.version; | ||
} |