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 {
|
||||
const m = __usePnpm(projectPath)
|
||||
? 'pnpm'
|
||||
: __useYarn(projectPath)
|
||||
? 'yarn'
|
||||
: __useNpm(projectPath)
|
||||
? __getNpmCommand()
|
||||
: __useCargo()
|
||||
? 'cargo'
|
||||
: null
|
||||
const isNodeProject = __isNodeProject(projectPath)
|
||||
if (isNodeProject) {
|
||||
if (__usePnpm(projectPath)) return 'pnpm'
|
||||
if (__useYarn(projectPath)) return 'yarn'
|
||||
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(`${projectPath}/package.json`, 'utf8')
|
||||
)
|
||||
|
||||
if (
|
||||
__useNpm(projectPath) &&
|
||||
packageJson.script &&
|
||||
packageJson.script['tauri']
|
||||
)
|
||||
return __getNpmCommand()
|
||||
}
|
||||
|
||||
if (__useCargo()) return 'cargo'
|
||||
|
||||
if (!m) {
|
||||
vscode.window.showErrorMessage(
|
||||
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
|
||||
)
|
||||
}
|
||||
|
||||
return m
|
||||
return null
|
||||
}
|
||||
|
||||
interface RunOptions {
|
||||
|
||||
Reference in New Issue
Block a user