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 middleware to open file in editor

  • 3.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NPM version Build Status Coverage Status Dependency Status

Express middleware to open any file in an editor by request to defined route. 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();

// There are few ways to setup:
// - to trigger middleware on *GET* request to `/open-in-editor`
app.get('/open-in-editor', openInEditor());

// - to trigger middleware on *any* request method to `/open-in-editor`
app.use('/open-in-editor', openInEditor());

// - to trigger middleware on *any* request method to *any* path
//   (not recommended unless server's single purpose is to open files in editor)
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 express-open-in-editor uses process.env.VISUAL or process.env.EDITOR (with this priority) to define the command to open a file in an editor. It could be set globally or on script execution:

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 setup see open-in-editor description.

Using with webpack-dev-server

Although webpack-dev-server uses express to create a server, you have the same options to apply the middleware to it. The only difference is that you should define it in setup method (see issue for details).

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

API

openInEditor([options]);

Options:

  • cwd

    Type: String
    Default: '' (uses process.cwd())

    Working directory used when resolving paths.

  • Rest options are passing to open-in-editor as is.

  • open-in-editor – package that do the main task of express-open-in-editor, i.e. opens file in editor.
  • babel-plugin-source-wrapperBabel plugin that instruments source code to associate objects with location they defined in code base.
  • Component Inspector – developer tool to inspect components that can open component creation source location in editor. Has integrations for React, Backbone and can be adopter for other frameworks.

License

MIT

Keywords

FAQs

Package last updated on 10 Nov 2017

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