Skip to content

Commit 77282c5

Browse files
committed
feat: eliminate "which" dependency
Use findNvim() instead of "which".
1 parent 555acfb commit 77282c5

File tree

13 files changed

+30
-157
lines changed

13 files changed

+30
-157
lines changed

package-lock.json

Lines changed: 1 addition & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/integration-tests/CHANGELOG.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/integration-tests/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: why is this a separate project? move this to packages/neovim

packages/integration-tests/__tests__/integration.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as fs from 'fs';
44
import * as path from 'path';
55
import * as http from 'http';
66

7-
import { NeovimClient, attach } from 'neovim';
7+
import { NeovimClient, attach, findNvim } from 'neovim';
88

99
describe('Node host', () => {
1010
const testdir = process.cwd();
@@ -36,10 +36,18 @@ describe('Node host', () => {
3636
let g:node_host_prog = '${path.resolve(plugdir, '../../neovim/bin/cli')}'
3737
`
3838
);
39-
cp.spawnSync('nvim', args);
39+
40+
const minVersion = '0.9.5'
41+
const nvimInfo = findNvim({ minVersion: minVersion });
42+
const nvimPath = nvimInfo.matches[0]?.path;
43+
if (!nvimPath) {
44+
throw new Error(`nvim ${minVersion} not found`)
45+
}
46+
47+
cp.spawnSync(nvimPath, args);
4048

4149
proc = cp.spawn(
42-
'nvim',
50+
nvimPath,
4351
['-u', nvimrc, '-i', 'NONE', '--headless', '--embed', '-n'],
4452
{}
4553
);

packages/neovim/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@
5959
"@babel/preset-typescript": "^7.23.3",
6060
"@types/jest": "^29.5.12",
6161
"@types/node": "16.9.x",
62-
"@types/which": "^3.0.3",
6362
"babel-jest": "^29.7.0",
6463
"jest": "^29.7.0",
6564
"jest-haste-map": "^29.7.0",
6665
"jest-resolve": "^29.6.1",
6766
"typedoc": "^0.25.7",
68-
"typescript": "^5.3.3",
69-
"which": "^4.0.0"
67+
"typescript": "^5.3.3"
7068
},
7169
"scripts": {
7270
"doc": "typedoc --out doc --exclude '**/*.test.ts' src",

packages/neovim/src/api/Buffer.test.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/* eslint-env jest */
2-
// eslint-disable-next-line import/no-extraneous-dependencies
3-
import * as which from 'which';
42
import * as testUtil from '../testUtil';
53

64
function wait(ms: number): Promise<void> {
@@ -11,17 +9,6 @@ function wait(ms: number): Promise<void> {
119
});
1210
}
1311

14-
try {
15-
which.sync('nvim');
16-
} catch (e) {
17-
// eslint-disable-next-line no-console
18-
console.error(
19-
'A Neovim installation is required to run the tests',
20-
'(see https://github.com/neovim/neovim/wiki/Installing)'
21-
);
22-
process.exit(1);
23-
}
24-
2512
describe('Buffer API', () => {
2613
let nvim: ReturnType<typeof testUtil.getNvim>;
2714

@@ -405,7 +392,7 @@ describe('Buffer event updates', () => {
405392
});
406393

407394
afterAll(() => {
408-
testUtil.startNvim2();
395+
testUtil.stopNvim2();
409396
});
410397

411398
beforeEach(async () => {

packages/neovim/src/api/Neovim.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/* eslint-env jest */
22
import * as path from 'node:path';
3-
// eslint-disable-next-line import/no-extraneous-dependencies
4-
import * as which from 'which';
53
import { Neovim } from './Neovim';
64
import * as testUtil from '../testUtil';
75

8-
try {
9-
which.sync('nvim');
10-
} catch (e) {
11-
// eslint-disable-next-line no-console
12-
console.error(
13-
'A Neovim installation is required to run the tests',
14-
'(see https://github.com/neovim/neovim/wiki/Installing)'
15-
);
16-
process.exit(1);
17-
}
18-
196
describe('Neovim API', () => {
207
let nvim: ReturnType<typeof testUtil.getNvim>;
218

packages/neovim/src/api/Tabpage.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
/* eslint-env jest */
2-
// eslint-disable-next-line import/no-extraneous-dependencies
3-
import * as which from 'which';
42
import * as testUtil from '../testUtil';
53

6-
try {
7-
which.sync('nvim');
8-
} catch (e) {
9-
// eslint-disable-next-line no-console
10-
console.error(
11-
'A Neovim installation is required to run the tests',
12-
'(see https://github.com/neovim/neovim/blob/master/INSTALL.md)'
13-
);
14-
process.exit(1);
15-
}
16-
174
describe('Tabpage API', () => {
185
let nvim: ReturnType<typeof testUtil.getNvim>;
196

packages/neovim/src/api/Window.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
/* eslint-env jest */
2-
// eslint-disable-next-line import/no-extraneous-dependencies
3-
import * as which from 'which';
42
import * as testUtil from '../testUtil';
53

6-
try {
7-
which.sync('nvim');
8-
} catch (e) {
9-
// eslint-disable-next-line no-console
10-
console.error(
11-
'A Neovim installation is required to run the tests',
12-
'(see https://github.com/neovim/neovim/wiki/Installing)'
13-
);
14-
process.exit(1);
15-
}
16-
174
describe('Window API', () => {
185
let nvim: ReturnType<typeof testUtil.getNvim>;
196

packages/neovim/src/attach/attach.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
/* eslint-env jest */
2-
// eslint-disable-next-line import/no-extraneous-dependencies
3-
import * as which from 'which';
42
import { attach } from './attach';
53
import { Logger } from '../utils/logger';
64
import * as testUtil from '../testUtil';
75

8-
try {
9-
which.sync('nvim');
10-
} catch (e) {
11-
// eslint-disable-next-line no-console
12-
console.error(
13-
'A Neovim installation is required to run the tests',
14-
'(see https://github.com/neovim/neovim/wiki/Installing)'
15-
);
16-
process.exit(1);
17-
}
18-
196
describe('Nvim API', () => {
207
let nvim: ReturnType<typeof testUtil.getNvim>;
218
let requests;

0 commit comments

Comments
 (0)