mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-11 05:57:07 +03:00
fix: getNpmLatestVersion, getNpmPackageVersion without npm (#1088)
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
8388553670
commit
4a74bca390
5
.changes/updater-issue-without-npm
Normal file
5
.changes/updater-issue-without-npm
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"tauri.js": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes an issue with the dependency updater when NPM isn't installed.
|
@ -23,7 +23,12 @@ async function getCrateLatestVersion(crateName: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNpmLatestVersion(packageName: string): string {
|
function getNpmLatestVersion(packageName: string): string {
|
||||||
const child = crossSpawnSync('npm', ['show', packageName, 'version'], {
|
const usesYarn = existsSync(appResolve.app('yarn.lock'))
|
||||||
|
const cmd = usesYarn ? 'yarn' : 'npm'
|
||||||
|
const args = usesYarn
|
||||||
|
? ['--silent', 'info', packageName, 'version']
|
||||||
|
: ['show', packageName, 'version']
|
||||||
|
const child = crossSpawnSync(cmd, args, {
|
||||||
cwd: appDir
|
cwd: appDir
|
||||||
})
|
})
|
||||||
return String(child.output[1]).replace('\n', '')
|
return String(child.output[1]).replace('\n', '')
|
||||||
@ -32,12 +37,13 @@ function getNpmLatestVersion(packageName: string): string {
|
|||||||
async function getNpmPackageVersion(
|
async function getNpmPackageVersion(
|
||||||
packageName: string
|
packageName: string
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
|
const usesYarn = existsSync(appResolve.app('yarn.lock'))
|
||||||
|
const cmd = usesYarn ? 'yarn' : 'npm'
|
||||||
|
const args = usesYarn
|
||||||
|
? ['--silent', 'list', packageName, 'version', '--depth', '0']
|
||||||
|
: ['list', packageName, 'version', '--depth', '0']
|
||||||
return await new Promise((resolve) => {
|
return await new Promise((resolve) => {
|
||||||
const child = crossSpawnSync(
|
const child = crossSpawnSync(cmd, args, { cwd: appDir })
|
||||||
'npm',
|
|
||||||
['list', packageName, 'version', '--depth', '0'],
|
|
||||||
{ cwd: appDir }
|
|
||||||
)
|
|
||||||
const output = String(child.output[1])
|
const output = String(child.output[1])
|
||||||
// eslint-disable-next-line security/detect-non-literal-regexp
|
// eslint-disable-next-line security/detect-non-literal-regexp
|
||||||
const matches = new RegExp(packageName + '@(\\S+)', 'g').exec(output)
|
const matches = new RegExp(packageName + '@(\\S+)', 'g').exec(output)
|
||||||
|
Loading…
Reference in New Issue
Block a user