Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-04-29 08:44:13 +0400
committerisaacs <i@izs.me>2013-04-29 08:44:34 +0400
commite2fab098471e11cbc0870375f2448797083e4cd1 (patch)
tree7e12e1f1aea531fbe38cadb6608c461a3b871256 /node_modules/editor
parentf694376b664d0707b255383123e199f9ef464277 (diff)
editor@0.0.4
Diffstat (limited to 'node_modules/editor')
-rw-r--r--node_modules/editor/README.markdown54
-rw-r--r--node_modules/editor/example/beep.json5
-rw-r--r--node_modules/editor/example/edit.js4
-rw-r--r--node_modules/editor/index.js26
-rw-r--r--node_modules/editor/package.json44
5 files changed, 133 insertions, 0 deletions
diff --git a/node_modules/editor/README.markdown b/node_modules/editor/README.markdown
new file mode 100644
index 000000000..c1121cad2
--- /dev/null
+++ b/node_modules/editor/README.markdown
@@ -0,0 +1,54 @@
+editor
+======
+
+Launch $EDITOR in your program.
+
+example
+=======
+
+``` js
+var editor = require('editor');
+editor('beep.json', function (code, sig) {
+ console.log('finished editing with code ' + code);
+});
+```
+
+***
+
+```
+$ node edit.js
+```
+
+![editor](http://substack.net/images/screenshots/editor.png)
+
+```
+finished editing with code 0
+```
+
+methods
+=======
+
+``` js
+var editor = require('editor')
+```
+
+editor(file, opts={}, cb)
+-------------------------
+
+Launch the `$EDITOR` (or `opts.editor`) for `file`.
+
+When the editor exits, `cb(code, sig)` fires.
+
+install
+=======
+
+With [npm](http://npmjs.org) do:
+
+```
+npm install editor
+```
+
+license
+=======
+
+MIT
diff --git a/node_modules/editor/example/beep.json b/node_modules/editor/example/beep.json
new file mode 100644
index 000000000..ac07d2da8
--- /dev/null
+++ b/node_modules/editor/example/beep.json
@@ -0,0 +1,5 @@
+{
+ "a" : 3,
+ "b" : 4,
+ "c" : 5
+}
diff --git a/node_modules/editor/example/edit.js b/node_modules/editor/example/edit.js
new file mode 100644
index 000000000..ee1172871
--- /dev/null
+++ b/node_modules/editor/example/edit.js
@@ -0,0 +1,4 @@
+var editor = require('../');
+editor(__dirname + '/beep.json', function (code, sig) {
+ console.log('finished editing with code ' + code);
+});
diff --git a/node_modules/editor/index.js b/node_modules/editor/index.js
new file mode 100644
index 000000000..8f1a3ebef
--- /dev/null
+++ b/node_modules/editor/index.js
@@ -0,0 +1,26 @@
+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;
+
+ setRaw(true);
+ var ps = spawn(editor, [ file ], { customFds : [ 0, 1, 2 ] });
+
+ ps.on('exit', function (code, sig) {
+ setRaw(false);
+ process.stdin.pause();
+ if (typeof cb === 'function') cb(code, sig)
+ });
+};
+
+var tty = require('tty');
+function setRaw (mode) {
+ process.stdin.setRawMode ? process.stdin.setRawMode(mode) : tty.setRawMode(mode);
+}
diff --git a/node_modules/editor/package.json b/node_modules/editor/package.json
new file mode 100644
index 000000000..cbeada377
--- /dev/null
+++ b/node_modules/editor/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "editor",
+ "version": "0.0.4",
+ "description": "launch $EDITOR in your program",
+ "main": "index.js",
+ "bin": {},
+ "directories": {
+ "example": "example",
+ "test": "test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "tap": "~0.2.5"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/node-editor.git"
+ },
+ "homepage": "https://github.com/substack/node-editor",
+ "keywords": [
+ "text",
+ "edit",
+ "shell"
+ ],
+ "author": {
+ "name": "James Halliday",
+ "email": "mail@substack.net",
+ "url": "http://substack.net"
+ },
+ "license": "MIT",
+ "engine": {
+ "node": ">=0.6"
+ },
+ "readme": "editor\n======\n\nLaunch $EDITOR in your program.\n\nexample\n=======\n\n``` js\nvar editor = require('editor');\neditor('beep.json', function (code, sig) {\n console.log('finished editing with code ' + code);\n});\n```\n\n***\n\n```\n$ node edit.js\n```\n\n![editor](http://substack.net/images/screenshots/editor.png)\n\n```\nfinished editing with code 0\n```\n\nmethods\n=======\n\n``` js\nvar editor = require('editor')\n```\n\neditor(file, opts={}, cb)\n-------------------------\n\nLaunch the `$EDITOR` (or `opts.editor`) for `file`.\n\nWhen the editor exits, `cb(code, sig)` fires.\n\ninstall\n=======\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install editor\n```\n\nlicense\n=======\n\nMIT\n",
+ "readmeFilename": "README.markdown",
+ "bugs": {
+ "url": "https://github.com/substack/node-editor/issues"
+ },
+ "_id": "editor@0.0.4",
+ "_from": "editor@"
+}