How to use the env-editor.defaultEditor function in env-editor

To help you get started, we’ve selected a few env-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / open-editor / index.js View on Github external
const make = (files, options = {}) => {
	if (!Array.isArray(files)) {
		throw new TypeError(`Expected an \`Array\`, got ${typeof files}`);
	}

	const editor = options.editor ? envEditor.getEditor(options.editor) : envEditor.defaultEditor();
	const editorArguments = [];

	if (editor.id === 'vscode') {
		editorArguments.push('--goto');
	}

	for (const file of files) {
		const parsed = lineColumnPath.parse(file);

		if (['sublime', 'atom', 'vscode'].includes(editor.id)) {
			editorArguments.push(lineColumnPath.stringify(parsed));
			continue;
		}

		if (['webstorm', 'intellij'].includes(editor.id)) {
			editorArguments.push(lineColumnPath.stringify(parsed, {column: false}));

env-editor

Get metadata on the default editor or a specific editor

MIT
Latest version published 3 years ago

Package Health Score

68 / 100
Full package analysis