yeet
This commit is contained in:
21
node_modules/external-editor/LICENSE
generated
vendored
Normal file
21
node_modules/external-editor/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Kevin Gravier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
151
node_modules/external-editor/README.md
generated
vendored
Normal file
151
node_modules/external-editor/README.md
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
# External Editor
|
||||
|
||||
[](https://travis-ci.org/mrkmg/node-external-editor/branches)
|
||||
[](https://www.npmjs.com/package/external-editor)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
|
||||
A node module to edit a string with a users preferred text editor using $VISUAL or $ENVIRONMENT.
|
||||
|
||||
Version: 2.2.0
|
||||
|
||||
As of version 2.0.0, node 0.10 is no longer support. Minimum node version is now 0.12.
|
||||
|
||||
## Install
|
||||
|
||||
`npm install external-editor --save`
|
||||
|
||||
## Usage
|
||||
|
||||
A simple example using the `.edit` convenience method
|
||||
|
||||
var ExternalEditor = require('external-editor')
|
||||
var data = ExternalEditor.edit('\n\n# Please write your text above');
|
||||
console.log(data);
|
||||
|
||||
A full featured example
|
||||
|
||||
var ExternalEditor = require('external-editor');
|
||||
|
||||
try {
|
||||
var editor = new ExternalEditor();
|
||||
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) {
|
||||
if (err instanceOf ExternalEditor.CreateFileError) {
|
||||
console.log('Failed to create the temporary file');
|
||||
} else if (err instanceOf ExternalEditor.ReadFileError) {
|
||||
console.log('Failed to read the temporary file');
|
||||
} else if (err instanceOf ExternalEditor.LaunchEditorError) {
|
||||
console.log('Failed to launch your editor');
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// Do things with the text
|
||||
|
||||
// Eventually call the cleanup to remove the temporary file
|
||||
try {
|
||||
editor.cleanup();
|
||||
} catch (err) {
|
||||
if (err instanceOf ExternalEditor.RemoveFileError) {
|
||||
console.log('Failed to remove the temporary file');
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#### API
|
||||
**Static Methods**
|
||||
|
||||
- `edit(text)`
|
||||
- `text` (string) *Optional* Defaults to empty string
|
||||
- **Returns** (string) The contents of the file
|
||||
- Could throw `CreateFileError`, `ReadFileError`, or `LaunchEditorError`, or `RemoveFileError`
|
||||
- `editAsync(text, callback)`
|
||||
- `text` (string) *Optional* Defaults to empty string
|
||||
- `callback` (function (error, text))
|
||||
- `error` could be of type `CreateFileError`, `ReadFileError`, or `LaunchEditorError`, or `RemoveFileError`
|
||||
- `text`(string) The contents of the file
|
||||
|
||||
|
||||
**Static Properties**
|
||||
|
||||
- `CreateFileError` Error thrown if the temporary file could not be created.
|
||||
- `ReadFileError` Error thrown if the temporary file could not be read.
|
||||
- `RemoveFileError` Error thrown if the temporary file could not be removed during cleanup.
|
||||
- `LaunchEditorError` Error thrown if the editor could not be launched.
|
||||
|
||||
**Public Methods**
|
||||
|
||||
- `new ExternalEditor(text)`
|
||||
- `text` (string) *Optional* Defaults to empty string
|
||||
- Could throw `CreateFileError`
|
||||
- `run()` Launches the editor.
|
||||
- **Returns** (string) The contents of the file
|
||||
- Could throw `LaunchEditorError` or `ReadFileError`
|
||||
- `runAsync(callback)` Launches the editor in an async way
|
||||
- `callback` (function (error, text))
|
||||
- `error` could be of type `ReadFileError` or `LaunchEditorError`
|
||||
- `text`(string) The contents of the file
|
||||
- `cleanup()` Removes the temporary file.
|
||||
- Could throw `RemoveFileError`
|
||||
|
||||
**Public Properties**
|
||||
|
||||
- `text` (string) *readonly* The text in the temporary file.
|
||||
- `editor.bin` (string) The editor determined from the environment.
|
||||
- `editor.args` (array) Default arguments for the bin
|
||||
- `temp_file` (string) Path to temporary file. Can be changed, but be careful as the temporary file probably already
|
||||
exists and would need be removed manually.
|
||||
- `last_exit_status` (number) The last exit code emitted from the editor.
|
||||
|
||||
## Errors
|
||||
|
||||
All errors have a simple message explaining what went wrong. They all also have an `original_error` property containing
|
||||
the original error thrown for debugging purposes.
|
||||
|
||||
## Why Synchronous?
|
||||
|
||||
Everything is synchronous to make sure the editor has complete control of the stdin and stdout. Testing has shown
|
||||
async launching of the editor can lead to issues when using readline or other packages which try to read from stdin or
|
||||
write to stdout. Seeing as this will be used in an interactive CLI environment, I made the decision to force the package
|
||||
to be synchronous. If you know a reliable way to force all stdin and stdout to be limited only to the child_process,
|
||||
please submit a PR.
|
||||
|
||||
If async is really needed, you can use `editAsync` or `runAsync`. If you are using readline or have anything else
|
||||
listening to the stdin or you write to stdout, you will most likely have problem, so make sure to remove any other
|
||||
listeners on stdin, stdout, or stdin.
|
||||
|
||||
## Demo
|
||||
|
||||
[](https://asciinema.org/a/a1qh9lypbe65mj0ivfuoslz2s)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Kevin Gravier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
40
node_modules/external-editor/example_async.js
generated
vendored
Normal file
40
node_modules/external-editor/example_async.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
var ExternalEditor = require('./main');
|
||||
var readline = require('readline');
|
||||
|
||||
var rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: null
|
||||
});
|
||||
|
||||
var message = '\n\n# Please Write a message\n# Any line starting with # is ignored';
|
||||
|
||||
process.stdout.write('Please write a message. (press enter to launch your preferred editor)');
|
||||
|
||||
editor = new ExternalEditor(message);
|
||||
|
||||
rl.on('line', function () {
|
||||
try {
|
||||
rl.pause();
|
||||
editor.runAsync(function (error, response)
|
||||
{
|
||||
if (error) {
|
||||
process.stdout.write(error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
if (response.length === 0) {
|
||||
readline.moveCursor(process.stdout, 0, -1);
|
||||
process.stdout.write('Your message was empty, please try again. (press enter to launch your preferred editor)');
|
||||
rl.resume();
|
||||
} else {
|
||||
process.stdout.write('Your Message:\n');
|
||||
process.stdout.write(response);
|
||||
process.stdout.write('\n');
|
||||
rl.close();
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
process.stderr.write(err.message);
|
||||
process.stdout.write('\n');
|
||||
rl.close();
|
||||
}
|
||||
});
|
38
node_modules/external-editor/example_sync.js
generated
vendored
Normal file
38
node_modules/external-editor/example_sync.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
var ExternalEditor = require('./main');
|
||||
var readline = require('readline');
|
||||
|
||||
var rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: null
|
||||
});
|
||||
|
||||
var message = '\n\n# Please Write a message\n# Any line starting with # is ignored';
|
||||
|
||||
process.stdout.write('Please write a message. (press enter to launch your preferred editor)');
|
||||
|
||||
editor = new ExternalEditor(message);
|
||||
|
||||
rl.on('line', function () {
|
||||
try {
|
||||
// Get response, remove all lines starting with #, remove any trailing newlines.
|
||||
var response = editor.run().replace(/^#.*\n?/gm, '').replace(/\n+$/g, '').trim();
|
||||
|
||||
if (editor.last_exit_status !== 0) {
|
||||
process.stderr.write("WARN: The editor exited with a non-zero status\n\n")
|
||||
}
|
||||
|
||||
if (response.length === 0) {
|
||||
readline.moveCursor(process.stdout, 0, -1);
|
||||
process.stdout.write('Your message was empty, please try again. (press enter to launch your preferred editor)');
|
||||
} else {
|
||||
process.stdout.write('Your Message:\n');
|
||||
process.stdout.write(response);
|
||||
process.stdout.write('\n');
|
||||
rl.close();
|
||||
}
|
||||
} catch (err) {
|
||||
process.stderr.write(err.message);
|
||||
process.stdout.write('\n');
|
||||
rl.close();
|
||||
}
|
||||
});
|
29
node_modules/external-editor/main/errors/CreateFileError.js
generated
vendored
Normal file
29
node_modules/external-editor/main/errors/CreateFileError.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
|
||||
/*
|
||||
ExternalEditor
|
||||
Kevin Gravier <kevin@mrkmg.com>
|
||||
MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var CreateFileError,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
CreateFileError = (function(superClass) {
|
||||
extend(CreateFileError, superClass);
|
||||
|
||||
CreateFileError.prototype.message = 'Failed to create temporary file for editor';
|
||||
|
||||
function CreateFileError(original_error) {
|
||||
this.original_error = original_error;
|
||||
}
|
||||
|
||||
return CreateFileError;
|
||||
|
||||
})(Error);
|
||||
|
||||
module.exports = CreateFileError;
|
||||
|
||||
}).call(this);
|
29
node_modules/external-editor/main/errors/LaunchEditorError.js
generated
vendored
Normal file
29
node_modules/external-editor/main/errors/LaunchEditorError.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
|
||||
/*
|
||||
ExternalEditor
|
||||
Kevin Gravier <kevin@mrkmg.com>
|
||||
MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var LaunchEditorError,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
LaunchEditorError = (function(superClass) {
|
||||
extend(LaunchEditorError, superClass);
|
||||
|
||||
LaunchEditorError.prototype.message = 'Failed launch editor';
|
||||
|
||||
function LaunchEditorError(original_error) {
|
||||
this.original_error = original_error;
|
||||
}
|
||||
|
||||
return LaunchEditorError;
|
||||
|
||||
})(Error);
|
||||
|
||||
module.exports = LaunchEditorError;
|
||||
|
||||
}).call(this);
|
29
node_modules/external-editor/main/errors/ReadFileError.js
generated
vendored
Normal file
29
node_modules/external-editor/main/errors/ReadFileError.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
|
||||
/*
|
||||
ExternalEditor
|
||||
Kevin Gravier <kevin@mrkmg.com>
|
||||
MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var ReadFileError,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
ReadFileError = (function(superClass) {
|
||||
extend(ReadFileError, superClass);
|
||||
|
||||
ReadFileError.prototype.message = 'Failed to read temporary file';
|
||||
|
||||
function ReadFileError(original_error) {
|
||||
this.original_error = original_error;
|
||||
}
|
||||
|
||||
return ReadFileError;
|
||||
|
||||
})(Error);
|
||||
|
||||
module.exports = ReadFileError;
|
||||
|
||||
}).call(this);
|
29
node_modules/external-editor/main/errors/RemoveFileError.js
generated
vendored
Normal file
29
node_modules/external-editor/main/errors/RemoveFileError.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
|
||||
/*
|
||||
ExternalEditor
|
||||
Kevin Gravier <kevin@mrkmg.com>
|
||||
MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var RemoveFileError,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
RemoveFileError = (function(superClass) {
|
||||
extend(RemoveFileError, superClass);
|
||||
|
||||
RemoveFileError.prototype.message = 'Failed to cleanup temporary file';
|
||||
|
||||
function RemoveFileError(original_error) {
|
||||
this.original_error = original_error;
|
||||
}
|
||||
|
||||
return RemoveFileError;
|
||||
|
||||
})(Error);
|
||||
|
||||
module.exports = RemoveFileError;
|
||||
|
||||
}).call(this);
|
229
node_modules/external-editor/main/index.js
generated
vendored
Normal file
229
node_modules/external-editor/main/index.js
generated
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
|
||||
/*
|
||||
ExternalEditor
|
||||
Kevin Gravier <kevin@mrkmg.com>
|
||||
MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var ChatDet, CreateFileError, ExternalEditor, FS, IConvLite, LaunchEditorError, ReadFileError, RemoveFileError, Spawn, SpawnSync, Temp,
|
||||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
FS = require('fs');
|
||||
|
||||
Temp = require('tmp');
|
||||
|
||||
SpawnSync = require('child_process').spawnSync;
|
||||
|
||||
Spawn = require('child_process').spawn;
|
||||
|
||||
IConvLite = require('iconv-lite');
|
||||
|
||||
ChatDet = require('chardet');
|
||||
|
||||
CreateFileError = require('./errors/CreateFileError');
|
||||
|
||||
ReadFileError = require('./errors/ReadFileError');
|
||||
|
||||
RemoveFileError = require('./errors/RemoveFileError');
|
||||
|
||||
LaunchEditorError = require('./errors/LaunchEditorError');
|
||||
|
||||
ExternalEditor = (function() {
|
||||
ExternalEditor.edit = function(text) {
|
||||
var editor;
|
||||
if (text == null) {
|
||||
text = '';
|
||||
}
|
||||
editor = new ExternalEditor(text);
|
||||
editor.run();
|
||||
editor.cleanup();
|
||||
return editor.text;
|
||||
};
|
||||
|
||||
ExternalEditor.editAsync = function(text, callback) {
|
||||
var editor;
|
||||
if (text == null) {
|
||||
text = '';
|
||||
}
|
||||
editor = new ExternalEditor(text);
|
||||
return editor.runAsync(function(error_run, text) {
|
||||
var error_cleanup;
|
||||
if (!error_run) {
|
||||
try {
|
||||
editor.cleanup();
|
||||
if (typeof callback === 'function') {
|
||||
return setImmediate(callback, null, text);
|
||||
}
|
||||
} catch (error) {
|
||||
error_cleanup = error;
|
||||
if (typeof callback === 'function') {
|
||||
return setImmediate(callback, error_cleanup, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (typeof callback === 'function') {
|
||||
return setImmediate(callback, error_run, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ExternalEditor.CreateFileError = CreateFileError;
|
||||
|
||||
ExternalEditor.ReadFileError = ReadFileError;
|
||||
|
||||
ExternalEditor.RemoveFileError = RemoveFileError;
|
||||
|
||||
ExternalEditor.LaunchEditorError = LaunchEditorError;
|
||||
|
||||
ExternalEditor.prototype.text = '';
|
||||
|
||||
ExternalEditor.prototype.temp_file = void 0;
|
||||
|
||||
ExternalEditor.prototype.editor = {
|
||||
bin: void 0,
|
||||
args: []
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.last_exit_status = void 0;
|
||||
|
||||
function ExternalEditor(text1) {
|
||||
this.text = text1 != null ? text1 : '';
|
||||
this.launchEditorAsync = bind(this.launchEditorAsync, this);
|
||||
this.launchEditor = bind(this.launchEditor, this);
|
||||
this.removeTemporaryFile = bind(this.removeTemporaryFile, this);
|
||||
this.readTemporaryFile = bind(this.readTemporaryFile, this);
|
||||
this.createTemporaryFile = bind(this.createTemporaryFile, this);
|
||||
this.determineEditor = bind(this.determineEditor, this);
|
||||
this.cleanup = bind(this.cleanup, this);
|
||||
this.runAsync = bind(this.runAsync, this);
|
||||
this.run = bind(this.run, this);
|
||||
this.determineEditor();
|
||||
this.createTemporaryFile();
|
||||
}
|
||||
|
||||
ExternalEditor.prototype.run = function() {
|
||||
this.launchEditor();
|
||||
return this.readTemporaryFile();
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.runAsync = function(callback) {
|
||||
var error_launch;
|
||||
try {
|
||||
return this.launchEditorAsync((function(_this) {
|
||||
return function() {
|
||||
var error_read;
|
||||
try {
|
||||
_this.readTemporaryFile();
|
||||
if (typeof callback === 'function') {
|
||||
return setImmediate(callback, null, _this.text);
|
||||
}
|
||||
} catch (error) {
|
||||
error_read = error;
|
||||
if (typeof callback === 'function') {
|
||||
return setImmediate(callback, error_read, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
} catch (error) {
|
||||
error_launch = error;
|
||||
if (typeof callback === 'function') {
|
||||
return setImmediate(callback, error_launch, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.cleanup = function() {
|
||||
return this.removeTemporaryFile();
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.determineEditor = function() {
|
||||
var args, ed, editor;
|
||||
ed = /^win/.test(process.platform) ? 'notepad' : 'vim';
|
||||
editor = process.env.VISUAL || process.env.EDITOR || ed;
|
||||
args = editor.split(/\s+/);
|
||||
this.editor.bin = args.shift();
|
||||
return this.editor.args = args;
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.createTemporaryFile = function() {
|
||||
var e;
|
||||
try {
|
||||
this.temp_file = Temp.tmpNameSync({});
|
||||
return FS.writeFileSync(this.temp_file, this.text, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
} catch (error) {
|
||||
e = error;
|
||||
throw new CreateFileError(e);
|
||||
}
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.readTemporaryFile = function() {
|
||||
var buffer, e, encoding;
|
||||
try {
|
||||
buffer = FS.readFileSync(this.temp_file);
|
||||
if (!buffer.length) {
|
||||
return this.text = '';
|
||||
}
|
||||
encoding = ChatDet.detect(buffer);
|
||||
return this.text = IConvLite.decode(buffer, encoding);
|
||||
} catch (error) {
|
||||
e = error;
|
||||
throw new ReadFileError(e);
|
||||
}
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.removeTemporaryFile = function() {
|
||||
var e;
|
||||
try {
|
||||
return FS.unlinkSync(this.temp_file);
|
||||
} catch (error) {
|
||||
e = error;
|
||||
throw new RemoveFileError(e);
|
||||
}
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.launchEditor = function() {
|
||||
var e, run;
|
||||
try {
|
||||
run = SpawnSync(this.editor.bin, this.editor.args.concat([this.temp_file]), {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
return this.last_exit_status = run.status;
|
||||
} catch (error) {
|
||||
e = error;
|
||||
throw new LaunchEditorError(e);
|
||||
}
|
||||
};
|
||||
|
||||
ExternalEditor.prototype.launchEditorAsync = function(callback) {
|
||||
var child_process, e;
|
||||
try {
|
||||
child_process = Spawn(this.editor.bin, this.editor.args.concat([this.temp_file]), {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
return child_process.on('exit', (function(_this) {
|
||||
return function(code) {
|
||||
_this.last_exit_status = code;
|
||||
if (typeof callback === 'function') {
|
||||
return callback();
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
} catch (error) {
|
||||
e = error;
|
||||
throw new LaunchEditorError(e);
|
||||
}
|
||||
};
|
||||
|
||||
return ExternalEditor;
|
||||
|
||||
})();
|
||||
|
||||
module.exports = ExternalEditor;
|
||||
|
||||
}).call(this);
|
47
node_modules/external-editor/package.json
generated
vendored
Normal file
47
node_modules/external-editor/package.json
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "external-editor",
|
||||
"version": "2.2.0",
|
||||
"description": "Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT",
|
||||
"main": "main/index.js",
|
||||
"scripts": {
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "mocha --recursive --compilers coffee:coffee-script/register --timeout 10000 ./test/spec",
|
||||
"compile": "coffee --compile --output main/ src/",
|
||||
"lint": "coffeelint -f .coffeelint.json src"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mrkmg/node-external-editor.git"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"external",
|
||||
"user",
|
||||
"visual"
|
||||
],
|
||||
"author": "Kevin Gravier <kevin@mrkmg.com> (https://mrkmg.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mrkmg/node-external-editor/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mrkmg/node-external-editor#readme",
|
||||
"dependencies": {
|
||||
"chardet": "^0.4.0",
|
||||
"iconv-lite": "^0.4.17",
|
||||
"tmp": "^0.0.33"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.0.0",
|
||||
"coffee-script": "^1.10.0",
|
||||
"coffeelint": "^1.14.2",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"files": [
|
||||
"main",
|
||||
"example_sync.js",
|
||||
"example_async.js"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user