env-editor

Get metadata on the default editor or a specific editor

MIT 13 个版本
安装
npm install env-editor
yarn add env-editor
pnpm add env-editor
bun add env-editor
README

env-editor

Get metadata on the default editor or a specific editor

This module is used by open-editor.

Supported editors

  • Sublime Text
  • Atom
  • Visual Studio Code
  • Visual Studio Code - Insiders
  • VSCodium
  • WebStorm
  • TextMate
  • Vim
  • NeoVim
  • IntelliJ
  • GNU nano
  • GNU Emacs
  • Android Studio
  • Xcode

Install

npm install env-editor

Usage

import {defaultEditor, getEditor, allEditors} from 'env-editor';

defaultEditor();
/*
{
	id: 'atom',
	name: 'Atom',
	binary: 'atom',
	isTerminalEditor: false,
	paths: [
		'/Applications/Atom.app/Contents/Resources/app/atom.sh'
	],
	keywords: []
}
*/

getEditor('sublime');
/*
{
	id: 'sublime',
	name: 'Sublime Text',
	binary: 'subl',
	isTerminalEditor: false,
	paths: [
		'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl',
		'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'
	],
	keywords: []
}
*/

allEditors();
/*
[
	{
		id: 'atom',
	},
	{
		id: 'sublime,
	},
]
*/

API

defaultEditor()

Returns metadata on the default editor.

The user is expected to have the $EDITOR environment variable set, and if not, a user-friendly error is thrown.

getEditor(editor)

Returns metadata on the specified editor.

editor

Type: string

This can be pretty flexible. It matches against all the data it has.

For example, to get Sublime Text, you could write either of the following: sublime, Sublime Text, subl.

allEditors()

Returns an array with metadata on all the editors.

版本列表
1.3.0 2025-09-10
1.2.0 2025-09-09
1.1.0 2022-04-24
1.0.0 2021-08-27
0.5.0 2021-02-06
0.4.2 2021-01-31
0.4.1 2019-09-18
0.4.0 2019-04-18
0.3.1 2017-05-07
0.3.0 2017-05-07
0.2.0 2017-05-07
0.1.1 2017-05-04
0.1.0 2017-05-04