Skip to content

Commit

Permalink
fix: install tauri-cli using cargo (#242)
Browse files Browse the repository at this point in the history
* fix: install tauri-cli using cargo

Signed-off-by: Soorya U <[email protected]>

* chore: better error message and updated function name

* change file

---------

Signed-off-by: Soorya U <[email protected]>
  • Loading branch information
soorya-u authored Apr 24, 2024
1 parent a8eb631 commit 8f41ede
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/cargo-tauri-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-vscode": patch
---

Install `cargo tauri` if not installed.
12 changes: 9 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function runTauriInit(): void {
let onInstall = () => {};
if (__isVueCliApp(projectPath)) {
installCommand = 'vue add tauri';
} else {
} else if (__isNodeProject(projectPath)) {
installCommand = __usePnpm(projectPath)
? 'pnpm add -D @tauri-apps/cli'
: __useYarn(projectPath)
Expand All @@ -185,6 +185,8 @@ function runTauriInit(): void {
noOutputWindow: true,
});
};
} else {
installCommand = 'cargo install tauri-cli';
}

const [command, ...args] = installCommand.split(' ');
Expand All @@ -196,7 +198,7 @@ function runTauriInit(): void {
() => {
const paths = __getNpmProjectsPaths();
return paths.filter((p) => {
return !fs.existsSync(path.join(p, 'src-tauri'));
return fs.existsSync(path.join(p, 'src-tauri'));
});
}
);
Expand Down Expand Up @@ -225,6 +227,10 @@ function __isVueCliApp(cwd: string): boolean {
return '@vue/cli-service' in (packageJson?.devDependencies ?? {});
}

function __isNodeProject(cwd: string): boolean {
return existsSync(join(cwd, 'package.json'));
}

interface PackageJson {
dependencies: {
[name: string]: any;
Expand Down Expand Up @@ -418,7 +424,7 @@ function __getPackageManagerCommand(projectPath: string): string | null {

if (!m) {
vscode.window.showErrorMessage(
"Couldn't detect package manager for current project."
"Couldn't detect package manager for current project. Try running Tauri: Init Command"
);
}

Expand Down

0 comments on commit 8f41ede

Please sign in to comment.