{ "_args": [ [ { "raw": "external-editor@^2.0.4", "scope": null, "escapedName": "external-editor", "name": "external-editor", "rawSpec": "^2.0.4", "spec": ">=2.0.4 <3.0.0", "type": "range" }, "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/inquirer" ] ], "_from": "external-editor@>=2.0.4 <3.0.0", "_id": "external-editor@2.1.0", "_inCache": true, "_location": "/external-editor", "_nodeVersion": "9.1.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/external-editor-2.1.0.tgz_1510928081377_0.6571654360741377" }, "_npmUser": { "name": "mrkmg", "email": "kevin@mrkmg.com" }, "_npmVersion": "5.5.1", "_phantomChildren": {}, "_requested": { "raw": "external-editor@^2.0.4", "scope": null, "escapedName": "external-editor", "name": "external-editor", "rawSpec": "^2.0.4", "spec": ">=2.0.4 <3.0.0", "type": "range" }, "_requiredBy": [ "/inquirer" ], "_resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", "_shasum": "3d026a21b7f95b5726387d4200ac160d372c3b48", "_shrinkwrap": null, "_spec": "external-editor@^2.0.4", "_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/inquirer", "author": { "name": "Kevin Gravier", "email": "kevin@mrkmg.com", "url": "https://mrkmg.com" }, "bugs": { "url": "https://github.com/mrkmg/node-external-editor/issues" }, "dependencies": { "chardet": "^0.4.0", "iconv-lite": "^0.4.17", "tmp": "^0.0.33" }, "description": "Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT", "devDependencies": { "chai": "^4.0.0", "coffee-script": "^1.10.0", "coffeelint": "^1.14.2", "mocha": "^3.2.0" }, "directories": {}, "dist": { "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", "shasum": "3d026a21b7f95b5726387d4200ac160d372c3b48", "tarball": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz" }, "engines": { "node": ">=0.12" }, "files": [ "main", "example_sync.js", "example_async.js" ], "gitHead": "056e00b7a8d0ad397590a7746aa7299d070eaccd", "homepage": "https://github.com/mrkmg/node-external-editor#readme", "keywords": [ "editor", "external", "user", "visual" ], "license": "MIT", "main": "main/index.js", "maintainers": [ { "name": "mrkmg", "email": "kevin@mrkmg.com" } ], "name": "external-editor", "optionalDependencies": {}, "readme": "# External Editor\n\n[![ExternalEditor on Travis CI](https://img.shields.io/travis/mrkmg/node-external-editor.svg?style=flat-square)](https://travis-ci.org/mrkmg/node-external-editor/branches)\n[![ExternalEditor on NPM](https://img.shields.io/npm/v/external-editor.svg?style=flat-square)](https://www.npmjs.com/package/external-editor)\n[![ExternalEditor uses the MIT](https://img.shields.io/npm/l/external-editor.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n\n\nA node module to edit a string with a users preferred text editor using $VISUAL or $ENVIRONMENT.\n\nVersion: 2.1.0\n\nAs of version 2.0.0, node 0.10 is no longer support. Minimum node version is now 0.12.\n\n## Install\n\n`npm install external-editor --save`\n\n## Usage\n\nA simple example using the `.edit` convenience method\n\n var ExternalEditor = require('external-editor')\n var data = ExternalEditor.edit('\\n\\n# Please write your text above');\n console.log(data);\n\nA full featured example\n\n var ExternalEditor = require('external-editor');\n \n try {\n var editor = new ExternalEditor();\n var text = editor.run()\n // the text is also available in editor.text\n } catch (err) {\n if (err instanceOf ExternalEditor.CreateFileError) {\n console.log('Failed to create the temporary file');\n } else if (err instanceOf ExternalEditor.ReadFileError) {\n console.log('Failed to read the temporary file');\n } else if (err instanceOf ExternalEditor.LaunchEditorError) {\n console.log('Failed to launch your editor');\n } else {\n throw err;\n }\n }\n \n // Do things with the text\n \n // Eventually call the cleanup to remove the temporary file\n try {\n editor.cleanup(); \n } catch (err) {\n if (err instanceOf ExternalEditor.RemoveFileError) {\n console.log('Failed to remove the temporary file');\n } else {\n throw err\n }\n }\n \n \n#### API\n**Static Methods**\n\n- `edit(text)`\n - `text` (string) *Optional* Defaults to empty string\n - **Returns** (string) The contents of the file\n - Could throw `CreateFileError`, `ReadFileError`, or `LaunchEditorError`, or `RemoveFileError`\n- `editAsync(text, callback)`\n - `text` (string) *Optional* Defaults to empty string\n - `callback` (function (error, text))\n - `error` could be of type `CreateFileError`, `ReadFileError`, or `LaunchEditorError`, or `RemoveFileError`\n - `text`(string) The contents of the file \n\n\n**Static Properties**\n\n- `CreateFileError` Error thrown if the temporary file could not be created. \n- `ReadFileError` Error thrown if the temporary file could not be read.\n- `RemoveFileError` Error thrown if the temporary file could not be removed during cleanup.\n- `LaunchEditorError` Error thrown if the editor could not be launched.\n\n**Public Methods**\n\n- `new ExternalEditor(text)`\n - `text` (string) *Optional* Defaults to empty string\n - Could throw `CreateFileError`\n- `run()` Launches the editor.\n - **Returns** (string) The contents of the file\n - Could throw `LaunchEditorError` or `ReadFileError`\n- `runAsync(callback)` Launches the editor in an async way\n - `callback` (function (error, text))\n - `error` could be of type `ReadFileError` or `LaunchEditorError`\n - `text`(string) The contents of the file\n- `cleanup()` Removes the temporary file.\n - Could throw `RemoveFileError`\n \n**Public Properties**\n\n- `text` (string) *readonly* The text in the temporary file.\n- `editor.bin` (string) The editor determined from the environment.\n- `editor.args` (array) Default arguments for the bin\n- `temp_file` (string) Path to temporary file. Can be changed, but be careful as the temporary file probably already \n exists and would need be removed manually.\n \n## Errors\n\nAll errors have a simple message explaining what went wrong. They all also have an `original_error` property containing\nthe original error thrown for debugging purposes.\n \n## Why Synchronous?\n \nEverything is synchronous to make sure the editor has complete control of the stdin and stdout. Testing has shown \nasync launching of the editor can lead to issues when using readline or other packages which try to read from stdin or \nwrite to stdout. Seeing as this will be used in an interactive CLI environment, I made the decision to force the package\nto be synchronous. If you know a reliable way to force all stdin and stdout to be limited only to the child_process,\nplease submit a PR.\n\nIf async is really needed, you can use `editAsync` or `runAsync`. If you are using readline or have anything else\nlistening to the stdin or you write to stdout, you will most likely have problem, so make sure to remove any other \nlisteners on stdin, stdout, or stdin.\n\n## Demo\n\n[![asciicast](https://asciinema.org/a/a1qh9lypbe65mj0ivfuoslz2s.png)](https://asciinema.org/a/a1qh9lypbe65mj0ivfuoslz2s)\n \n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Kevin Gravier\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/mrkmg/node-external-editor.git" }, "scripts": { "compile": "coffee --compile --output main/ src/", "lint": "coffeelint -f .coffeelint.json src", "test": "npm run lint && npm run unit", "unit": "mocha --recursive --compilers coffee:coffee-script/register --timeout 10000 ./test/spec" }, "version": "2.1.0" }