Skip to content

Commit

Permalink
Update node modules installation check to npm exclusively (#14)
Browse files Browse the repository at this point in the history
This PR restricts listing installed node modules to `npm` only. At the
same time it fixes the issue which marke node modules as installed even
if they were not present.

Before:
The check to verify packages was performed using different package
managers.

After:
Now we use only `npm` to determine the presence of node modules. `npm`
is included with `node` so there's no risk that user won't have it.
  • Loading branch information
franciszekjob authored Mar 22, 2024
1 parent 863925d commit f8339f8
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions packages/vscode-extension/src/dependency/DependencyChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { command } from "../utilities/subprocess";
import path from "path";
import { getIosSourceDir } from "../builders/buildIOS";
import { getAppRootFolder } from "../utilities/extensionContext";
import { resolvePackageManager } from "../utilities/packageManager";

export class DependencyChecker implements Disposable {
private disposables: Disposable[] = [];
Expand Down Expand Up @@ -78,25 +77,10 @@ export class DependencyChecker implements Disposable {
}

public async checkNodeModulesInstalled() {
let installed = false;
const packageManager = await resolvePackageManager();
if (packageManager === "yarn") {
installed = await checkIfCLIInstalled(`yarn list --json`, {
cwd: getAppRootFolder(),
});
} else if (packageManager === "pnpm") {
installed = await checkIfCLIInstalled(`pnpm list --json`, {
cwd: getAppRootFolder(),
});
} else if (packageManager === "bun") {
installed = await checkIfCLIInstalled(`bun pm ls --json`, {
cwd: getAppRootFolder(),
});
} else {
installed = await checkIfCLIInstalled(`npm list --json`, {
cwd: getAppRootFolder(),
});
}
const installed = await checkIfCLIInstalled(`npm list --json`, {
cwd: getAppRootFolder(),
});

const errorMessage = "Node modules are not installed.";
this.webview.postMessage({
command: "isNodeModulesInstalled",
Expand Down

0 comments on commit f8339f8

Please sign in to comment.