Socket
Socket
Sign inDemoInstall

open-in-editor

Package Overview
Dependencies
10
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

HISTORY.md

5

lib/editors/index.js
module.exports = {
atom: require('./atom'),
code: require('./code'),
sublime: require('./sublime')
sublime: require('./sublime'),
webstorm: require('./webstorm'),
phpstorm: require('./phpstorm'),
idea14ce: require('./idea14ce')
};

11

package.json
{
"name": "open-in-editor",
"description": "Open file in editor",
"version": "1.0.1",
"version": "1.1.0",
"author": "Roman Dvornov <rdvornov@gmail.com>",

@@ -11,6 +11,11 @@ "license": "MIT",

"file",
"editor"
"editor",
"atom",
"code",
"idea",
"phpstorm",
"webstorm",
"sublime"
],
"main": "./lib/index.js",
"preferGlobal": true,
"bin": {

@@ -17,0 +22,0 @@ "oe": "./bin/oe"

[![NPM version](https://img.shields.io/npm/v/open-in-editor.svg)](https://www.npmjs.com/package/open-in-editor)
Simplify file open in editor.
Opens files in editor.

@@ -10,8 +10,11 @@ Supported editors:

- [Visual Studio Code](https://code.visualstudio.com/)
- [WebStorm](https://www.jetbrains.com/webstorm/)
- [PhpStorm](https://www.jetbrains.com/phpstorm/)
- [IDEA 14 Community Edition](https://www.jetbrains.com/idea/download/)
But you also can use any other editor that supported file opening by terminal command.
You also can use any other editor that is able to open files from command line.
> More editors are comming soon, PRs are welcome.
> Support for more editors is comming soon. PRs are welcomed!
## Install
## Installation

@@ -24,3 +27,3 @@ ```

First of all you should create interface with your settings.
First of all you should create an interface with your settings.

@@ -32,7 +35,7 @@ ```js

}, function(err) {
console.error('Something goes wrong: ' + err);
console.error('Something went wrong: ' + err);
});
```
Created interface have single method `open`. This method runs terminal command that opens editor. Result of method is Promise instance:
Resulting object has a single method `open`. This method runs terminal command that opens an editor. Result of this method is a promise:

@@ -44,3 +47,3 @@ ```js

}, function(err) {
console.error('Something goes wrong: ' + err);
console.error('Something went wrong: ' + err);
});

@@ -57,6 +60,6 @@ ```

- `options` – *optional* uses for setup command to launch editor. If no options set it will try to get command from [environment](#Environment)
- `failCallback` – *optional* function that calls when something goes wrong on editor setup.
- `options` – *optional* is used to set up a command to launch an editor. If no options set it will try to get the command from [environment](#environment)
- `failCallback` – *optional* function that is called when something's wrong with editor setup.
If editor is set up successful `configure` method returns interface with single method `open`. `open` method accepts file reference in format: `filename[:line[:column]]`. `line` and `column` tells editor where to place cursor when file is opened.
If editor setup was successful `configure` method returns an interface with single method `open`. The method accepts file reference with the following format: `filename[:line[:column]]`, where `line` and `column` tell the editor where to place cursor when file is opened.

@@ -69,7 +72,7 @@ ### Options

Values: `sublime`, `atom`, `code`
Values: `sublime`, `atom`, `code`, `webstorm`, `phpstorm`, `idea14ce`
Default: *not set*
Allows set editor to open file. Option accepts one preset value. When some value is set, we try to detect command to launch editor if possible.
Editor that will be used to open a file. Once value is set, we try to detect a command to launch the editor.

@@ -81,2 +84,5 @@ Supported editors:

- `code` – Visual Studio Code
- `webstorm` – WebStorm
- `phpstorm` - PhpStorm
- `idea14ce` – IDEA 14 CE

@@ -89,5 +95,5 @@ #### cmd

Specify command to launch editor. If some value set to option then `editor` is ignoring.
Command that will be used to launch the editor. If this option is set, `editor` is ignored.
Command could contains some patterns to be replaced by actual values. Supported values: `filename`, `line` and `column`.
Command could contain placeholders that will be replaced by actual values. Supported placeholders: `filename`, `line` and `column`.

@@ -101,3 +107,3 @@ ```js

If no `{filename}` pattern in command then `{filename}:{line}:{column}` is appending. So, previous example could be simplified:
If there's no `{filename}` placholder in the command then `{filename}:{line}:{column}` is appended. That way previous example could be simplified:

@@ -117,3 +123,3 @@ ```js

Defines what is the first line in filename reference that pass to `open`method. Usually it's lines starts with `1`. But you can pass file offset starts with `0`.
Defines the number of the first line in the editor. Usually it's `1`, but you can set it to `0`.

@@ -126,7 +132,8 @@ #### column

Defines what is the first coulmn in filename reference that pass to `open`method. Usually it's coulmns starts with `1`. But you can pass file offset starts with `0`.
Defines the number of the first column in the editor. Usually it's `1`, but you can set it to `0`.
## Environment
If no `editor` or `cmd` value specified, we try to get command to launch editor from environment settings. Follow values could be used (in descending of priority):
If no `editor` or `cmd` value specified, we try to get the command to launch editor using environment settings. Following values could be used (in descending priority):

@@ -137,5 +144,5 @@ - `process.env.OPEN_FILE`

If any value found it uses as value for `cmd` option. But `OPEN_FILE` a little bit different: if value is one of allowed values for `editor` it uses as value for `editor` option, otherwise it uses as value for `cmd`.
First value found is used. If it's `process.env.VISUAL` or `process.env.EDITOR`, it's used directly as `cmd` option. But `process.env.OPEN_FILE` is different: if value is allowed for `editor` parameter, it's used as a value for `editor` option, otherwise it's used as a value for `cmd` option.
You can set env setting on any command launch:
You can set env settings per command:

@@ -155,3 +162,3 @@ ```

In this case `oe` command will be available in terminal. Usage of command:
In this case `oe` command will be available in terminal.

@@ -167,6 +174,6 @@ ```

--debug Debug errors
-e, --editor <editor> Editor: atom, code, sublime
-e, --editor <editor> Editor: atom, code, sublime, webstorm, phpstorm, idea14ce
-f, --file <filename> File to open
-h, --help Output usage information
-v, --version Output the version
-v, --version Output version
```

@@ -173,0 +180,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc