aboutsummaryrefslogtreecommitdiff
path: root/deps/node/deps/npm/node_modules/editor/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node/deps/npm/node_modules/editor/index.js')
-rw-r--r--deps/node/deps/npm/node_modules/editor/index.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/deps/node/deps/npm/node_modules/editor/index.js b/deps/node/deps/npm/node_modules/editor/index.js
new file mode 100644
index 00000000..3774edbe
--- /dev/null
+++ b/deps/node/deps/npm/node_modules/editor/index.js
@@ -0,0 +1,20 @@
+var spawn = require('child_process').spawn;
+
+module.exports = function (file, opts, cb) {
+ if (typeof opts === 'function') {
+ cb = opts;
+ opts = {};
+ }
+ if (!opts) opts = {};
+
+ var ed = /^win/.test(process.platform) ? 'notepad' : 'vim';
+ var editor = opts.editor || process.env.VISUAL || process.env.EDITOR || ed;
+ var args = editor.split(/\s+/);
+ var bin = args.shift();
+
+ var ps = spawn(bin, args.concat([ file ]), { stdio: 'inherit' });
+
+ ps.on('exit', function (code, sig) {
+ if (typeof cb === 'function') cb(code, sig)
+ });
+};