[Pkg-javascript-commits] [node-editor] 01/03: Import Upstream version 1.0.0

Saravanan Palanisamy saravanan30erd-guest at moszumanska.debian.org
Wed Jun 28 18:20:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

saravanan30erd-guest pushed a commit to branch master
in repository node-editor.

commit 7e12b06c6b3fb59d71f126a19036f0fae457bcf5
Author: saravanan30erd <saravanan30erd at gmail.com>
Date:   Wed Jun 28 14:16:01 2017 -0400

    Import Upstream version 1.0.0
---
 LICENSE           | 21 +++++++++++++++++++++
 README.markdown   | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 example/beep.json |  5 +++++
 example/edit.js   |  4 ++++
 index.js          | 20 ++++++++++++++++++++
 package.json      | 34 ++++++++++++++++++++++++++++++++++
 6 files changed, 138 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8b856bc
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+Copyright 2013 James Halliday (mail at substack.net)
+
+This project is free software released under the MIT license:
+
+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.
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..c1121ca
--- /dev/null
+++ b/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/example/beep.json b/example/beep.json
new file mode 100644
index 0000000..ac07d2d
--- /dev/null
+++ b/example/beep.json
@@ -0,0 +1,5 @@
+{
+  "a" : 3,
+  "b" : 4,
+  "c" : 5
+}
diff --git a/example/edit.js b/example/edit.js
new file mode 100644
index 0000000..ee11728
--- /dev/null
+++ b/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/index.js b/index.js
new file mode 100644
index 0000000..3774edb
--- /dev/null
+++ b/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)
+    });
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..d956a68
--- /dev/null
+++ b/package.json
@@ -0,0 +1,34 @@
+{
+    "name" : "editor",
+    "version" : "1.0.0",
+    "description" : "launch $EDITOR in your program",
+    "main" : "index.js",
+    "directories" : {
+        "example" : "example",
+        "test" : "test"
+    },
+    "dependencies" : {},
+    "devDependencies" : {
+        "tap" : "~0.4.4"
+    },
+    "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 at substack.net",
+        "url" : "http://substack.net"
+    },
+    "license" : "MIT",
+    "engine" : { "node" : ">=0.6" }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-editor.git



More information about the Pkg-javascript-commits mailing list