VscodeAdblockSyntax
VscodeAdblockSyntax copied to clipboard
Automatically detect package manager
VSCode has a command to detect the package manager: npm.packageManager
.
This setting could be combined with our package manager logic to make the process automatic (in the current solution, user can only set the preferred package manager manually).
References:
- https://github.com/microsoft/vscode/issues/102050
- https://github.com/shivangg/vscode/blob/master/extensions/npm/README.md#settings
- https://code.visualstudio.com/api/extension-guides/command#using-a-custom-when-clause-context
import { commands } from 'vscode'; // ... await commands.executeCommand<'npm' | 'pnpm' | 'yarn'>('npm.packageManager')
If I understand correctly, this cannot be used directly in the language server, so there are two options:
- pass detected package manager from client to server
- an alternative solution might be to detect the lock file type (VSCode also does this)