diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/external-editor')
7 files changed, 41 insertions, 23 deletions
diff --git a/tools/node_modules/eslint/node_modules/external-editor/README.md b/tools/node_modules/eslint/node_modules/external-editor/README.md index a6c69017ea..9eb135b643 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/README.md +++ b/tools/node_modules/eslint/node_modules/external-editor/README.md @@ -7,7 +7,7 @@ A node module to edit a string with a users preferred text editor using $VISUAL or $ENVIRONMENT. -Version: 3.0.3 +Version: 3.1.0 As of version 3.0.0, the minimum version of node supported is 4. @@ -63,15 +63,17 @@ A full featured example #### API **Convenience Methods** -- `edit(text)` +- `edit(text, config)` - `text` (string) *Optional* Defaults to empty string + - `config` (Config) *Optional* Options for temporary file creation - **Returns** (string) The contents of the file - Could throw `CreateFileError`, `ReadFileError`, or `LaunchEditorError`, or `RemoveFileError` -- `editAsync(text, callback)` +- `editAsync(text, callback, config)` - `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 + - `text`(string) The contents of the file + - `config` (Config) *Optional* Options for temporary file creation **Errors** @@ -83,8 +85,9 @@ A full featured example **External Editor Public Methods** -- `new ExternalEditor(text)` +- `new ExternalEditor(text, config)` - `text` (string) *Optional* Defaults to empty string + - `config` (Config) *Optional* Options for temporary file creation - Could throw `CreateFileError` - `run()` Launches the editor. - **Returns** (string) The contents of the file @@ -105,6 +108,14 @@ A full featured example exists and would need be removed manually. - `lastExitStatus` (number) The last exit code emitted from the editor. +**Config Options** + +- `prefix` (string) *Optional* A prefix for the file name. +- `postfix` (string; *Optional* A postfix for the file name. Useful if you want to provide an extension. +- `mode` (number) *Optional* Which mode to create the file with. e.g. 644 +- `template` (string) *Optional* A template for the filename. See [tmp](https://www.npmjs.com/package/tmp). +- `dir` (string) *Optional* Which path to store the file. + ## Errors All errors have a simple message explaining what went wrong. They all also have an `originalError` property containing diff --git a/tools/node_modules/eslint/node_modules/external-editor/main/errors/CreateFileError.js b/tools/node_modules/eslint/node_modules/external-editor/main/errors/CreateFileError.js index ca3f876d9e..7faa34c82c 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/main/errors/CreateFileError.js +++ b/tools/node_modules/eslint/node_modules/external-editor/main/errors/CreateFileError.js @@ -11,7 +11,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tools/node_modules/eslint/node_modules/external-editor/main/errors/LaunchEditorError.js b/tools/node_modules/eslint/node_modules/external-editor/main/errors/LaunchEditorError.js index 3ab4817989..85a164e7a8 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/main/errors/LaunchEditorError.js +++ b/tools/node_modules/eslint/node_modules/external-editor/main/errors/LaunchEditorError.js @@ -11,7 +11,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tools/node_modules/eslint/node_modules/external-editor/main/errors/ReadFileError.js b/tools/node_modules/eslint/node_modules/external-editor/main/errors/ReadFileError.js index 7845d8deda..69e0513627 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/main/errors/ReadFileError.js +++ b/tools/node_modules/eslint/node_modules/external-editor/main/errors/ReadFileError.js @@ -11,7 +11,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tools/node_modules/eslint/node_modules/external-editor/main/errors/RemoveFileError.js b/tools/node_modules/eslint/node_modules/external-editor/main/errors/RemoveFileError.js index 238570870e..23d266f248 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/main/errors/RemoveFileError.js +++ b/tools/node_modules/eslint/node_modules/external-editor/main/errors/RemoveFileError.js @@ -11,7 +11,7 @@ var __extends = (this && this.__extends) || (function () { ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); - } + }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } diff --git a/tools/node_modules/eslint/node_modules/external-editor/main/index.js b/tools/node_modules/eslint/node_modules/external-editor/main/index.js index 3fa210e4b3..258f31964b 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/main/index.js +++ b/tools/node_modules/eslint/node_modules/external-editor/main/index.js @@ -3,7 +3,7 @@ * Node External Editor * * Kevin Gravier <kevin@mrkmg.com> - * MIT 2018 + * MIT 2019 */ Object.defineProperty(exports, "__esModule", { value: true }); var chardet_1 = require("chardet"); @@ -19,17 +19,17 @@ var ReadFileError_1 = require("./errors/ReadFileError"); exports.ReadFileError = ReadFileError_1.ReadFileError; var RemoveFileError_1 = require("./errors/RemoveFileError"); exports.RemoveFileError = RemoveFileError_1.RemoveFileError; -function edit(text) { +function edit(text, fileOptions) { if (text === void 0) { text = ""; } - var editor = new ExternalEditor(text); + var editor = new ExternalEditor(text, fileOptions); editor.run(); editor.cleanup(); return editor.text; } exports.edit = edit; -function editAsync(text, callback) { +function editAsync(text, callback, fileOptions) { if (text === void 0) { text = ""; } - var editor = new ExternalEditor(text); + var editor = new ExternalEditor(text, fileOptions); editor.runAsync(function (err, result) { if (err) { setImmediate(callback, err, null); @@ -47,10 +47,14 @@ function editAsync(text, callback) { } exports.editAsync = editAsync; var ExternalEditor = /** @class */ (function () { - function ExternalEditor(text) { + function ExternalEditor(text, fileOptions) { if (text === void 0) { text = ""; } this.text = ""; + this.fileOptions = {}; this.text = text; + if (fileOptions) { + this.fileOptions = fileOptions; + } this.determineEditor(); this.createTemporaryFile(); } @@ -124,8 +128,12 @@ var ExternalEditor = /** @class */ (function () { }; ExternalEditor.prototype.createTemporaryFile = function () { try { - this.tempFile = tmp_1.tmpNameSync({}); - fs_1.writeFileSync(this.tempFile, this.text, { encoding: "utf8" }); + this.tempFile = tmp_1.tmpNameSync(this.fileOptions); + var opt = { encoding: "utf8" }; + if (this.fileOptions.hasOwnProperty("mode")) { + opt.mode = this.fileOptions.mode; + } + fs_1.writeFileSync(this.tempFile, this.text, opt); } catch (createFileError) { throw new CreateFileError_1.CreateFileError(createFileError); diff --git a/tools/node_modules/eslint/node_modules/external-editor/package.json b/tools/node_modules/eslint/node_modules/external-editor/package.json index c13988c0d3..ea87070894 100644 --- a/tools/node_modules/eslint/node_modules/external-editor/package.json +++ b/tools/node_modules/eslint/node_modules/external-editor/package.json @@ -26,14 +26,14 @@ "@types/chai": "^4.1.4", "@types/chardet": "^0.5.0", "@types/mocha": "^5.2.5", - "@types/node": "^10.9.4", + "@types/node": "^10.14.12", "@types/tmp": "0.0.33", "chai": "^4.0.0", "es6-shim": "^0.35.3", "mocha": "^5.2.0", "ts-node": "^7.0.1", - "tslint": "^5.11.0", - "typescript": "^3.0.3" + "tslint": "^5.18.0", + "typescript": "^3.5.2" }, "engines": { "node": ">=4" @@ -60,9 +60,8 @@ "scripts": { "compile": "tsc -p tsconfig.json", "lint": "tslint './src/**/*.ts' './test/**/*.ts'", - "test": "npm run lint && npm run unit", - "unit": "mocha --recursive --require ts-node/register --timeout 10000 ./test/spec 'test/spec/**/*.ts'" + "test": "mocha --recursive --require ts-node/register --timeout 10000 ./test/spec 'test/spec/**/*.ts'" }, "types": "main/index.d.ts", - "version": "3.0.3" + "version": "3.1.0" }
\ No newline at end of file |