403Webshell
Server IP : 159.203.156.69  /  Your IP : 216.73.216.28
Web Server : nginx/1.24.0
System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/thread-self/root/lib/node_modules/pm2/lib/tools/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/root/lib/node_modules/pm2/lib/tools/prompt.js
var readline = require('readline');

function prompt(message, opts, cb) {
  if (typeof opts === 'function') { cb = opts; opts = {}; }
  var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
  rl.question(message, function(answer) {
    rl.close();
    if (opts.validator) {
      try {
        answer = opts.validator(answer);
      } catch(e) {
        if (opts.retry) {
          console.error(e.message || e);
          return prompt(message, opts, cb);
        }
        return cb(e);
      }
    }
    cb(null, answer);
  });
}

function password(message, opts, cb) {
  var input = '';
  var replace = (opts && opts.replace) || '*';

  process.stdout.write(message);
  process.stdin.setRawMode(true);
  process.stdin.resume();
  process.stdin.setEncoding('utf8');

  var onData = function(ch) {
    if (ch === '\r' || ch === '\n') {
      process.stdin.setRawMode(false);
      process.stdin.pause();
      process.stdin.removeListener('data', onData);
      process.stdout.write('\n');
      cb(null, input);
    } else if (ch === '\u0003') {
      process.exit();
    } else if (ch === '\u007f' || ch === '\b') {
      if (input.length > 0) {
        input = input.slice(0, -1);
        process.stdout.write('\b \b');
      }
    } else {
      input += ch;
      process.stdout.write(replace);
    }
  };
  process.stdin.on('data', onData);
}

function confirm(message, cb) {
  prompt(message + ' ', function(err, answer) {
    if (err) return cb(err);
    cb(null, /^y(es)?$/i.test(answer.trim()));
  });
}

function choose(message, choices, cb) {
  console.log(choices.map(function(c, i) { return '  ' + (i + 1) + ') ' + c; }).join('\n'));
  prompt(message, function(err, answer) {
    if (err) return cb(err);
    answer = answer.trim();
    var idx = parseInt(answer, 10);
    if (idx >= 1 && idx <= choices.length) return cb(null, choices[idx - 1]);
    if (choices.indexOf(answer) !== -1) return cb(null, answer);
    return choose(message, choices, cb);
  });
}

exports.prompt = prompt;
exports.password = password;
exports.confirm = confirm;
exports.choose = choose;

Youez - 2016 - github.com/yon3zu
LinuXploit