From 0b2008a3131d77979c20d54417c1d3dc01953ae4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 15 Oct 2024 14:00:44 +0200 Subject: [PATCH] feat(findNvim): version parsing robustness Problem: Version parsing makes some assumptions about the `nvim -v` output that could be more robust. For example, - "NVIM" may change to "Nvim": https://github.com/neovim/neovim/commit/98ba65b8be8cb2dde839502357e70916c4a3e37a - "v" is not guaranteed to precede the version Solution: - match case-insensitive "NVIM" - match "v?" instead of "v" - Note: `--api-info` is not used because it is a big payload (thus requires streamed decoding, thus more complex code). --- CHANGELOG.md | 2 +- packages/neovim/src/utils/findNvim.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4f6b312..82152639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [5.4.0](https://github.com/neovim/node-client/compare/v5.3.0...v5.4.0) -- TODO +- feat(findNvim): version parsing robustness ## [5.3.0](https://github.com/neovim/node-client/compare/v5.2.1...v5.3.0) diff --git a/packages/neovim/src/utils/findNvim.ts b/packages/neovim/src/utils/findNvim.ts index 45098f6c..7ab38e3a 100644 --- a/packages/neovim/src/utils/findNvim.ts +++ b/packages/neovim/src/utils/findNvim.ts @@ -67,7 +67,7 @@ export type FindNvimResult = { }; const versionRegex = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/; -const nvimVersionRegex = /^NVIM\s+v(.+)$/m; +const nvimVersionRegex = /^[nN][vV][iI][mM]\s+v?(.+)$/m; const buildTypeRegex = /^Build\s+type:\s+(.+)$/m; const luaJitVersionRegex = /^LuaJIT\s+(.+)$/m; const windows = process.platform === 'win32';