aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
commit6555fb80fdd8f6a5d201efadec3189d1244830a0 (patch)
treec1aa1c5aedc634ad1ea7fad4847884d559b51290 /sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js
parent7d3640f824f46490b47bd95f1c5a16644f712068 (diff)
Izbrisala bin, obj i node-modules.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js100
1 files changed, 0 insertions, 100 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js b/sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js
deleted file mode 100644
index 600e0745..00000000
--- a/sandbox/testAppNevena/Front/node_modules/inquirer/lib/prompts/editor.js
+++ /dev/null
@@ -1,100 +0,0 @@
-'use strict';
-/**
- * `editor` type prompt
- */
-
-const chalk = require('chalk');
-const { editAsync } = require('external-editor');
-const Base = require('./base');
-const observe = require('../utils/events');
-const { Subject } = require('rxjs');
-
-class EditorPrompt extends Base {
- /**
- * Start the Inquiry session
- * @param {Function} cb Callback when prompt is done
- * @return {this}
- */
-
- _run(cb) {
- this.done = cb;
-
- this.editorResult = new Subject();
-
- // Open Editor on "line" (Enter Key)
- const events = observe(this.rl);
- this.lineSubscription = events.line.subscribe(this.startExternalEditor.bind(this));
-
- // Trigger Validation when editor closes
- const validation = this.handleSubmitEvents(this.editorResult);
- validation.success.forEach(this.onEnd.bind(this));
- validation.error.forEach(this.onError.bind(this));
-
- // Prevents default from being printed on screen (can look weird with multiple lines)
- this.currentText = this.opt.default;
- this.opt.default = null;
-
- // Init
- this.render();
-
- return this;
- }
-
- /**
- * Render the prompt to screen
- * @return {EditorPrompt} self
- */
-
- render(error) {
- let bottomContent = '';
- let message = this.getQuestion();
-
- if (this.status === 'answered') {
- message += chalk.dim('Received');
- } else {
- message += chalk.dim('Press <enter> to launch your preferred editor.');
- }
-
- if (error) {
- bottomContent = chalk.red('>> ') + error;
- }
-
- this.screen.render(message, bottomContent);
- }
-
- /**
- * Launch $EDITOR on user press enter
- */
-
- startExternalEditor() {
- // Pause Readline to prevent stdin and stdout from being modified while the editor is showing
- this.rl.pause();
- editAsync(this.currentText, this.endExternalEditor.bind(this));
- }
-
- endExternalEditor(error, result) {
- this.rl.resume();
- if (error) {
- this.editorResult.error(error);
- } else {
- this.editorResult.next(result);
- }
- }
-
- onEnd(state) {
- this.editorResult.unsubscribe();
- this.lineSubscription.unsubscribe();
- this.answer = state.value;
- this.status = 'answered';
- // Re-render prompt
- this.render();
- this.screen.done();
- this.done(this.answer);
- }
-
- onError(state) {
- this.render(state.isValid);
- }
-}
-
-module.exports = EditorPrompt;