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.1.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 any file in an 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 an editor at line 2 column 5.

By default extension uses process.env.VISUAL or process.env.EDITOR (with this priority) to get the command to open file in an 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 understands shorthands (i.e. subl for Sublime Text or atom for Atom Editor).

For more details about editor setup see open-in-editor.

Using with webpack-dev-server

Although webpack-dev-server uses express to create server, you can't use app.use() to apply extension. Instead you should define it in setup method (see issue for details).

var server = new WebpackDevServer(webpack(config), {
  // ...
  setup: function(app) {
    app.use(openInEditor());
  }
});

API

openInEditor([options]);

options

url

Type: String

Default: /open-in-editor

Request to this path triggers middleware.

editor

Type: String

Values: sublime, atom, code

Default: not set

Editor to open files. Option accepts one of preset values. When value is set, extension tries to detect command to launch an editor.

Supported editors:

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

Type: String

Default: not set

Command to launch an editor. This option overrides whatever is set in editor option.

Command could contain placeholders that will be replaced with actual values. Supported placeholders: filename, line and column.

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

If no {filename} placeholder is present, then {filename}:{line}:{column} is appended to the value of this option. That way previous example could be simplified:

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

License

MIT

Keywords

FAQs

Package last updated on 08 Nov 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