-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0954e1
commit 6baa272
Showing
4 changed files
with
64 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import console from 'node:console' | ||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
import { URL } from 'node:url' | ||
|
||
import { request } from '#src/utils.js' | ||
|
||
/** | ||
* @typedef {object} Versions | ||
* @property {string} latest Latest semver | ||
* @property {string} current Insttaled semver | ||
*/ | ||
|
||
/** | ||
* Get the installed version and the latest remote version of email-alias | ||
* | ||
* @returns {Versions} latest abd current version | ||
*/ | ||
export default async () => { | ||
const { latest } = await request( | ||
'https://registry.npmjs.org/-/package/@vafanassieff/email-alias/dist-tags' | ||
) | ||
|
||
const { version: current } = await fs | ||
.readFile( | ||
path.join(new URL('.', import.meta.url).pathname, '../package.json') | ||
) | ||
.then(JSON.parse) | ||
|
||
if (current !== latest) { | ||
console.log(`There is a new email-alias version !`) | ||
console.log(`You are running the ${current} latest is ${latest}`) | ||
console.log( | ||
'To update the version run npm update -g @vafanassieff/email-alias' | ||
) | ||
} | ||
|
||
return { current, latest } | ||
} |