New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

HISTORY.md

18

index.js

@@ -11,15 +11,9 @@ var parseUrl = require('parseurl');

var opener = configure(options, function(err) {
console.warn('open-in-editor configure error: ', err);
console.warn('[open-in-editor] configure error: ', err);
});
if (!opener) {
return function openInEditorFallback(req, res, next) {
next();
};
}
return function openInEditor(req, res, next) {
function fail(code, message) {
res.statusCode = code;
res.end(message);
res.end('[open-in-editor] ' + message);
}

@@ -42,2 +36,8 @@

if (!opener) {
var msg = 'Request to open file failed, editor is not set up';
console.warn('[open-in-editor] ', msg);
return fail(400, msg);
}
var filename = querystring.parse(parsedUrl.query).file;

@@ -61,3 +61,3 @@

function(e) {
fail(500, 'open-in-editor error: ' + e);
fail(500, 'ERROR: ' + e);
}

@@ -64,0 +64,0 @@ );

{
"name": "express-open-in-editor",
"version": "1.0.0",
"version": "1.1.0",
"description": "Express extension to open file in editor",

@@ -15,5 +15,4 @@ "author": "Roman Dvornov <rdvornov@gmail.com>",

],
"homepage": "https://github.com/lahmatiy/express-open-in-editor#readme",
"dependencies": {
"open-in-editor": "lahmatiy/open-in-editor",
"open-in-editor": "^1.1.0",
"parseurl": "~1.3.0"

@@ -20,0 +19,0 @@ },

[![NPM version](https://img.shields.io/npm/v/express-open-in-editor.svg)](https://www.npmjs.com/package/express-open-in-editor)
Express extension to open file in editor. Based on [open-in-editor](https://github.com/lahmatiy/open-in-editor).
Express extension to open any file in an editor. Based on [open-in-editor](https://github.com/lahmatiy/open-in-editor).

@@ -24,5 +24,5 @@ ## Install

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.
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 command to open file in editor. It could be set globally or with main script:
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:

@@ -33,6 +33,19 @@ ```

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`).
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`).
More details about editor setup see in [open-in-editor](https://github.com/lahmatiy/open-in-editor).
For more details about editor setup see [open-in-editor](https://github.com/lahmatiy/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](https://github.com/webpack/webpack-dev-server/issues/285) for details).
```js
var server = new WebpackDevServer(webpack(config), {
// ...
setup: function(app) {
app.use(openInEditor());
}
});
```
## API

@@ -52,3 +65,3 @@

Listen path.
Request to this path triggers middleware.

@@ -63,3 +76,3 @@ #### editor

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.
Editor to open files. Option accepts one of preset values. When value is set, extension tries to detect command to launch an editor.

@@ -78,5 +91,5 @@ Supported editors:

Specify command to launch editor. If some value set to option then `editor` is ignoring.
Command to launch an editor. This option overrides whatever is set in `editor` option.
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 with actual values. Supported placeholders: `filename`, `line` and `column`.

@@ -89,3 +102,3 @@ ```js

If no `{filename}` pattern in command found then `{filename}:{line}:{column}` is appending. So, previous example could be simplified:
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:

@@ -92,0 +105,0 @@ ```js

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