VscodeAdblockSyntax icon indicating copy to clipboard operation
VscodeAdblockSyntax copied to clipboard

Automatically detect package manager

Open scripthunter7 opened this issue 1 year ago • 0 comments

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)

scripthunter7 avatar Nov 08 '23 09:11 scripthunter7