-
-
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
e0d8adc
commit f97d107
Showing
4 changed files
with
109 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { bold, cyan, yellow } from 'picocolors' | ||
import checkForUpdate from 'update-check' | ||
|
||
import packageJson from '../../package.json' | ||
|
||
export async function checkUpdates(): Promise<void> { | ||
const userAgent = process.env.npm_config_user_agent || '' | ||
|
||
let packageManager = 'npm' | ||
|
||
if (userAgent.startsWith('yarn')) packageManager = 'yarn' | ||
|
||
if (userAgent.startsWith('pnpm')) packageManager = 'pnpm' | ||
|
||
if (userAgent.startsWith('bun')) packageManager = 'bun' | ||
|
||
try { | ||
const res = await checkForUpdate(packageJson).catch(() => null) | ||
|
||
if (res?.latest) { | ||
const updateMessage = | ||
packageManager === 'yarn' | ||
? 'yarn global add rapidbuild' | ||
: packageManager === 'pnpm' | ||
? 'pnpm add -g rapidbuild' | ||
: packageManager === 'bun' | ||
? 'bun add -g rapidbuild' | ||
: 'npm i -g rapidbuild' | ||
|
||
console.log( | ||
`\n${yellow(bold('A new version of `rapidbuild` is available!'))}\n\nYou can update by running: ${cyan(updateMessage)}\n`, | ||
) | ||
} | ||
|
||
process.exit() | ||
} catch { | ||
// ignore error | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.