Skip to content

Commit 053a222

Browse files
authored
Merge #316 rename getNvimFromEnv => findNvim
2 parents 37a0034 + b4a428d commit 053a222

File tree

6 files changed

+41
-47
lines changed

6 files changed

+41
-47
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ See below for a quickstart example that you can copy and run immediately.
1919

2020
The `neovim` package exposes these functions:
2121

22-
- `getNvimFromEnv`: Tries to find a usable `nvim` binary on the current system.
23-
- `attach`: The primary interface. Takes a process, socket, or pair of write/read streams and returns a `NeovimClient` connected to the `nvim` server.
22+
- `findNvim`: Tries to find a usable `nvim` binary on the current system.
23+
- `attach`: The primary interface. Takes a process, socket, or pair of write/read streams and returns a `NeovimClient` connected to an `nvim` process.
2424

2525
### Quickstart: connect to Nvim
2626

2727
Following is a complete, working example.
2828

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).
29+
1. Install the `neovim` package _locally_ (i.e. without `-g`. Node throws `ERR_MODULE_NOT_FOUND` if a script imports a _globally_ installed package).
3030
```bash
3131
npm install neovim
3232
```
@@ -38,11 +38,11 @@ Following is a complete, working example.
3838
```js
3939
import * as child_process from 'node:child_process'
4040
import * as assert from 'node:assert'
41-
import { attach, getNvimFromEnv } from 'neovim'
41+
import { attach, findNvim } from 'neovim'
4242

4343
// Find `nvim` on the system and open a channel to it.
4444
(async function() {
45-
const found = getNvimFromEnv({ orderBy: 'desc', minVersion: '0.9.0' })
45+
const found = findNvim({ orderBy: 'desc', minVersion: '0.9.0' })
4646
console.log(found);
4747
const nvim_proc = child_process.spawn(found.matches[0].path, ['--clean', '--embed'], {});
4848

@@ -190,27 +190,28 @@ See the tests and [`scripts`](https://github.com/neovim/node-client/tree/master/
190190

191191
## Maintain
192192

193-
Maintenance tasks:
194-
195193
### Release
196194

197195
Only maintainers of the [neovim NPM package](https://www.npmjs.com/package/neovim) can publish a release. Follow these steps to publish a release:
198196

199-
```bash
200-
cd packages/neovim
201-
# Choose major/minor/patch as needed.
202-
npm version patch
203-
cd -
204-
# Note: this copies the top-level README.md to packages/neovim.
205-
npm run publish:neovim
206-
207-
# Post-relase
208-
export _VERSION=$(grep -o 'version": "[^"]\+' packages/neovim/package.json | sed 's/.*"//')
209-
git tag "v${_VERSION}"
210-
cd packages/neovim/
211-
npm version --no-git-tag-version prerelease --preid dev && git add package*.json && git commit -m bump
212-
git push --follow-tags
213-
```
197+
1. Update `CHANGELOG.md`.
198+
2. Update version. Build and publish the package. Tag the release and push.
199+
```bash
200+
# Choose major/minor/patch as needed.
201+
npm version -w packages/neovim/ patch
202+
# Note: this copies the top-level README.md to packages/neovim.
203+
npm run publish:neovim
204+
export _VERSION=$(grep -o 'version": "[^"]\+' packages/neovim/package.json | sed 's/.*"//')
205+
git tag "v${_VERSION}"
206+
git push --follow-tags
207+
```
208+
3. Post-release tasks:
209+
```bash
210+
cd packages/neovim/
211+
npm version -w packages/neovim/ --no-git-tag-version prerelease --preid dev
212+
git add package*.json && git commit -m bump
213+
git push
214+
```
214215

215216
### Regenerate documentation website
216217

package-lock.json

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

packages/neovim/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "neovim",
33
"description": "Nvim msgpack API client and remote plugin provider",
4-
"version": "4.11.1-dev.0",
4+
"version": "5.0.1-dev.0",
55
"homepage": "https://github.com/neovim/node-client",
66
"authors": [
77
{

packages/neovim/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ export { Neovim, NeovimClient, Buffer, Tabpage, Window } from './api/index';
33
export { Plugin, Function, Autocmd, Command } from './plugin';
44
export { NvimPlugin } from './host/NvimPlugin';
55
export { loadPlugin } from './host/factory';
6-
export {
7-
getNvimFromEnv,
8-
GetNvimFromEnvOptions,
9-
GetNvimFromEnvResult,
10-
} from './utils/getNvimFromEnv';
6+
export { findNvim, FindNvimOptions, FindNvimResult } from './utils/findNvim';

packages/neovim/src/utils/getNvimFromEnv.test.ts renamed to packages/neovim/src/utils/findNvim.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
/* eslint-env jest */
22
// eslint-disable-next-line import/no-extraneous-dependencies
33
import which from 'which';
4-
import {
5-
getNvimFromEnv,
6-
exportsForTesting,
7-
GetNvimFromEnvResult,
8-
} from './getNvimFromEnv';
4+
import { findNvim, exportsForTesting, FindNvimResult } from './findNvim';
95

106
const parseVersion = exportsForTesting.parseVersion;
117
const compareVersions = exportsForTesting.compareVersions;
@@ -19,7 +15,7 @@ try {
1915
);
2016
}
2117

22-
describe('getNvimFromEnv', () => {
18+
describe('findNvim', () => {
2319
it('parseVersion()', () => {
2420
expect(parseVersion('0.5.0-dev+1357-g192f89ea1')).toEqual([
2521
0,
@@ -76,7 +72,7 @@ describe('getNvimFromEnv', () => {
7672
});
7773

7874
/** Asserts that >=1 nvim binaries were found. */
79-
function assertOneOrMore(nvimRes: Readonly<GetNvimFromEnvResult>) {
75+
function assertOneOrMore(nvimRes: Readonly<FindNvimResult>) {
8076
expect(nvimRes).toEqual({
8177
matches: expect.any(Array),
8278
invalid: expect.any(Array),
@@ -93,17 +89,17 @@ describe('getNvimFromEnv', () => {
9389
}
9490

9591
it('gets Nvim satisfying given min version', () => {
96-
const nvimRes = getNvimFromEnv({ minVersion: '0.3.0', orderBy: 'desc' });
92+
const nvimRes = findNvim({ minVersion: '0.3.0', orderBy: 'desc' });
9793
assertOneOrMore(nvimRes);
9894
});
9995

10096
it('gets Nvim without specified min version', () => {
101-
const nvimRes = getNvimFromEnv();
97+
const nvimRes = findNvim();
10298
assertOneOrMore(nvimRes);
10399
});
104100

105101
it('collects invalid matches separately', () => {
106-
const nvimRes = getNvimFromEnv({ minVersion: '9999.0.0' });
102+
const nvimRes = findNvim({ minVersion: '9999.0.0' });
107103
expect(nvimRes).toEqual({
108104
matches: [],
109105
invalid: expect.any(Array),

packages/neovim/src/utils/getNvimFromEnv.ts renamed to packages/neovim/src/utils/findNvim.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type NvimVersion = {
1515
readonly error?: Readonly<Error>;
1616
};
1717

18-
export type GetNvimFromEnvOptions = {
18+
export type FindNvimOptions = {
1919
/**
2020
* (Optional) Minimum `nvim` version (inclusive) to search for.
2121
*
@@ -25,15 +25,15 @@ export type GetNvimFromEnvOptions = {
2525
/**
2626
* (Optional) Sort order of list of `nvim` versions.
2727
*
28-
* - "desc" - Sort by version in descending order (highest to lowest).
28+
* - "desc" - (Default) Sort by version in descending order (highest to lowest).
2929
* - Example: `['0.5.0', '0.4.4', '0.4.3']`
30-
* - "none" - (Default) Order is that of the searched `$PATH` components.
30+
* - "none" - Order is that of the searched `$PATH` components.
3131
* - Example: `['0.4.4', '0.5.0', '0.4.3']`
3232
*/
3333
readonly orderBy?: 'desc' | 'none';
3434
};
3535

36-
export type GetNvimFromEnvResult = {
36+
export type FindNvimResult = {
3737
/**
3838
* List of satisfying `nvim` versions found (if any) on the current system, sorted in the order
3939
* specified by `orderBy`.
@@ -115,10 +115,11 @@ function compareVersions(a: string, b: string): number {
115115

116116
/**
117117
* Tries to find a usable `nvim` binary on the current system.
118+
*
119+
* @param opt.minVersion See {@link FindNvimOptions.minVersion}
120+
* @param opt.orderBy See {@link FindNvimOptions.orderBy}
118121
*/
119-
export function getNvimFromEnv(
120-
opt: GetNvimFromEnvOptions = {}
121-
): Readonly<GetNvimFromEnvResult> {
122+
export function findNvim(opt: FindNvimOptions = {}): Readonly<FindNvimResult> {
122123
const paths = process.env.PATH.split(delimiter);
123124
const pathLength = paths.length;
124125
const matches = new Array<NvimVersion>();
@@ -163,7 +164,7 @@ export function getNvimFromEnv(
163164
}
164165
}
165166

166-
if (opt.orderBy === 'desc') {
167+
if (opt.orderBy === undefined || opt.orderBy === 'desc') {
167168
matches.sort((a, b) => compareVersions(b.nvimVersion, a.nvimVersion));
168169
}
169170

0 commit comments

Comments
 (0)