Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-open-in-editor

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-open-in-editor

Express extension to open file in editor

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
302
decreased by-51.52%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version

Express extension to open file in editor. Based on open-in-editor.

Install

npm install express-open-in-editor

Usage

var express = require('express');
var openInEditor = require('express-open-in-editor');

var app = express();

app.use(openInEditor());

// ...

After that you can use GET requests like /open-in-editor?file=foo/bar.ext:2:5 to open foo/bar.ext in editor at line 2 column 5.

By default extension uses process.env.VISUAL or process.env.EDITOR (with this priority) to get command to open file in editor. It could be set globally or with main script:

EDITOR=subl node app.js

Also you can set process.env.OPEN_FILE, that has highest priority and could detect editor command to launch by it's short name (i.e. subl for Sublime Text or atom for Atom Editor).

More details about editor setup see in open-in-editor.

API

openInEditor([options]);

options

url

Type: String

Default: /open-in-editor

Listen path.

editor

Type: String

Values: sublime, atom, code

Default: not set

Allows set editor to open file. Option accepts one of preset value. When some value is set, extension try to detect command to launch editor if possible.

Supported editors:

  • sublime – Sublime Text
  • atom – Atom Editor
  • code – Visual Studio Code
cmd

Type: String

Default: not set

Specify command to launch editor. If some value set to option then editor is ignoring.

Command could contains some patterns to be replaced by actual values. Supported values: filename, line and column.

app.use(openInEditor({
  cmd: 'code -r -g {filename}:{line}:{column}'
}));

If no {filename} pattern in command found then {filename}:{line}:{column} is appending. So, previous example could be simplified:

app.use(openInEditor({
  cmd: 'code -r -g'
}));

License

MIT

Keywords

FAQs

Package last updated on 24 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc