mirror of
https://github.com/tauri-apps/tauri-vscode.git
synced 2026-01-31 00:35:18 +01:00
fix: Check for package.json file to get package manager (#282)
This commit is contained in:
5
.changes/fix-cargo.md
Normal file
5
.changes/fix-cargo.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'tauri-vscode': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix extension trying to use npm instead of cargo.
|
||||||
@@ -413,23 +413,30 @@ function __getNpmCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function __getPackageManagerCommand(projectPath: string): string | null {
|
function __getPackageManagerCommand(projectPath: string): string | null {
|
||||||
const m = __usePnpm(projectPath)
|
const isNodeProject = __isNodeProject(projectPath)
|
||||||
? 'pnpm'
|
if (isNodeProject) {
|
||||||
: __useYarn(projectPath)
|
if (__usePnpm(projectPath)) return 'pnpm'
|
||||||
? 'yarn'
|
if (__useYarn(projectPath)) return 'yarn'
|
||||||
: __useNpm(projectPath)
|
|
||||||
? __getNpmCommand()
|
const packageJson = JSON.parse(
|
||||||
: __useCargo()
|
fs.readFileSync(`${projectPath}/package.json`, 'utf8')
|
||||||
? 'cargo'
|
)
|
||||||
: null
|
|
||||||
|
if (
|
||||||
|
__useNpm(projectPath) &&
|
||||||
|
packageJson.script &&
|
||||||
|
packageJson.script['tauri']
|
||||||
|
)
|
||||||
|
return __getNpmCommand()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__useCargo()) return 'cargo'
|
||||||
|
|
||||||
if (!m) {
|
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
|
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
return m
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RunOptions {
|
interface RunOptions {
|
||||||
|
|||||||
Reference in New Issue
Block a user