Skip to content

Commit 37a0034

Browse files
authored
feat: eliminate "semver" dependency #313
This dependency is unnecessary.
1 parent 73ec691 commit 37a0034

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ The `neovim` package exposes these functions:
2424

2525
### Quickstart: connect to Nvim
2626

27-
Following is a complete example. Paste it into `demo.mjs` file and run it with `node demo.mjs`:
27+
Following is a complete, working example.
28+
29+
1. Install the `neovim` package _locally_ (i.e. without `-g`. Node will fail with `ERR_MODULE_NOT_FOUND` if a script tries to import a _globally_ installed package).
30+
```bash
31+
npm install neovim
32+
```
33+
2. Paste the script below into a `demo.mjs` file and run it!
34+
```
35+
node demo.mjs
36+
```
2837

2938
```js
3039
import * as child_process from 'node:child_process'

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/neovim/bin/cli.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
const { Host } = require('../lib/host');
33
const { logger } = require('../lib/utils/logger');
44
const { spawnSync } = require('child_process');
5-
const semver = require('semver');
65

76
// node <current script> <rest of args>
87
const [, , ...args] = process.argv;
@@ -15,9 +14,13 @@ if (args[0] === '--version') {
1514
process.exit(0);
1615
}
1716

17+
// "21.6.1" => "21"
18+
const nodeMajorVersionStr = process.versions.node.replace(/\..*/, '')
19+
const nodeMajorVersion = Number.parseInt(nodeMajorVersionStr ?? '0')
20+
1821
if (
1922
process.env.NVIM_NODE_HOST_DEBUG &&
20-
semver.satisfies(process.version, '>=7.6.0 || >=6.12.0 <7.0.0') &&
23+
nodeMajorVersion >= 8 &&
2124
process.execArgv.every(token => token !== '--inspect-brk')
2225
) {
2326
const childHost = spawnSync(

packages/neovim/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
},
5151
"dependencies": {
5252
"@msgpack/msgpack": "^2.8.0",
53-
"semver": "^7.5.4",
5453
"winston": "3.11.0"
5554
},
5655
"devDependencies": {

0 commit comments

Comments
 (0)