external-editor
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -20,2 +20,6 @@ var ExternalEditor = require('./main'); | ||
if (editor.last_exit_status !== 0) { | ||
process.stderr.write("WARN: The editor exited with a non-zero status\n\n") | ||
} | ||
if (response.length === 0) { | ||
@@ -22,0 +26,0 @@ readline.moveCursor(process.stdout, 0, -1); |
@@ -51,3 +51,3 @@ // Generated by CoffeeScript 1.12.7 | ||
editor = new ExternalEditor(text); | ||
return editor.runAsync(function(error_run, response) { | ||
return editor.runAsync(function(error_run, text) { | ||
var error_cleanup; | ||
@@ -57,11 +57,15 @@ if (!error_run) { | ||
editor.cleanup(); | ||
if (typeof callback === 'function') { | ||
return setImmediate(callback, null, text); | ||
} | ||
} catch (error) { | ||
error_cleanup = error; | ||
if (typeof callback === 'function') { | ||
callback(error_cleanup); | ||
return setImmediate(callback, error_cleanup, null); | ||
} | ||
} | ||
return callback(null, response); | ||
} else { | ||
return callback(error_run) in typeof callback === 'function'; | ||
if (typeof callback === 'function') { | ||
return setImmediate(callback, error_run, null); | ||
} | ||
} | ||
@@ -88,2 +92,4 @@ }); | ||
ExternalEditor.prototype.last_exit_status = void 0; | ||
function ExternalEditor(text1) { | ||
@@ -118,3 +124,3 @@ this.text = text1 != null ? text1 : ''; | ||
if (typeof callback === 'function') { | ||
return callback(null, _this.text); | ||
return setImmediate(callback, null, _this.text); | ||
} | ||
@@ -124,3 +130,3 @@ } catch (error) { | ||
if (typeof callback === 'function') { | ||
return callback(error_read); | ||
return setImmediate(callback, error_read, null); | ||
} | ||
@@ -133,3 +139,3 @@ } | ||
if (typeof callback === 'function') { | ||
return callback(error_launch); | ||
return setImmediate(callback, error_launch, null); | ||
} | ||
@@ -148,4 +154,4 @@ } | ||
args = editor.split(/\s+/); | ||
this.bin = args.shift(); | ||
return this.args = args; | ||
this.editor.bin = args.shift(); | ||
return this.editor.args = args; | ||
}; | ||
@@ -192,7 +198,8 @@ | ||
ExternalEditor.prototype.launchEditor = function() { | ||
var e; | ||
var e, run; | ||
try { | ||
return SpawnSync(this.bin, this.args.concat([this.temp_file]), { | ||
run = SpawnSync(this.editor.bin, this.editor.args.concat([this.temp_file]), { | ||
stdio: 'inherit' | ||
}); | ||
return this.last_exit_status = run.status; | ||
} catch (error) { | ||
@@ -207,10 +214,13 @@ e = error; | ||
try { | ||
child_process = Spawn(this.bin, this.args.concat([this.temp_file]), { | ||
child_process = Spawn(this.editor.bin, this.editor.args.concat([this.temp_file]), { | ||
stdio: 'inherit' | ||
}); | ||
return child_process.on('exit', function() { | ||
if (typeof callback === 'function') { | ||
return callback(); | ||
} | ||
}); | ||
return child_process.on('exit', (function(_this) { | ||
return function(code) { | ||
_this.last_exit_status = code; | ||
if (typeof callback === 'function') { | ||
return callback(); | ||
} | ||
}; | ||
})(this)); | ||
} catch (error) { | ||
@@ -217,0 +227,0 @@ e = error; |
{ | ||
"name": "external-editor", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT", | ||
@@ -5,0 +5,0 @@ "main": "main/index.js", |
@@ -10,3 +10,3 @@ # External Editor | ||
Version: 2.1.0 | ||
Version: 2.2.0 | ||
@@ -33,4 +33,7 @@ As of version 2.0.0, node 0.10 is no longer support. Minimum node version is now 0.12. | ||
var editor = new ExternalEditor(); | ||
var text = editor.run() | ||
// the text is also available in editor.text | ||
var text = editor.run() // the text is also available in editor.text | ||
if (editor.last_exit_status !== 0) { | ||
console.log("The editor exited with a non-zero code"); | ||
} | ||
} catch (err) { | ||
@@ -105,2 +108,3 @@ if (err instanceOf ExternalEditor.CreateFileError) { | ||
exists and would need be removed manually. | ||
- `last_exit_status` (number) The last exit code emitted from the editor. | ||
@@ -107,0 +111,0 @@ ## Errors |
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
20528
339
152