launch-editor-middleware
Advanced tools
Comparing version 2.1.0 to 2.2.0
17
index.js
const url = require('url') | ||
const path = require('path') | ||
const launch = require('launch-editor') | ||
module.exports = (specifiedEditor, onErrorCallback) => { | ||
module.exports = (specifiedEditor, srcRoot, onErrorCallback) => { | ||
if (typeof specifiedEditor === 'function') { | ||
onErrorCallback = specifiedEditor | ||
specifiedEditor = undefined | ||
} | ||
if (typeof srcRoot === 'function') { | ||
onErrorCallback = srcRoot | ||
srcRoot = undefined | ||
} | ||
srcRoot = srcRoot || process.cwd() | ||
return function launchEditorMiddleware (req, res, next) { | ||
@@ -11,3 +24,3 @@ const { file } = url.parse(req.url, true).query || {} | ||
} else { | ||
launch(file, specifiedEditor, onErrorCallback) | ||
launch(path.resolve(srcRoot, file), specifiedEditor, onErrorCallback) | ||
res.end() | ||
@@ -14,0 +27,0 @@ } |
{ | ||
"name": "launch-editor-middleware", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "express middleware for launching editor", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1347
24