UNPKG

data-provider-temporary

Version:

Library that helps with server-to-client synchronization of data

45 lines (39 loc) 1.41 kB
'use strict'; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * */ const chalk = require('chalk');var _require = require('../constants');const KEYS = _require.KEYS; module.exports = function ( pipe) {let stdin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : process.stdin; return new Promise((resolve, reject) => { if (typeof stdin.setRawMode === 'function') { const messages = [ chalk.red('There are deprecation warnings.\n'), chalk.dim(' \u203A Press ') + 'Enter' + chalk.dim(' to continue.'), chalk.dim(' \u203A Press ') + 'Esc' + chalk.dim(' to exit.')]; pipe.write(messages.join('\n')); // $FlowFixMe stdin.setRawMode(true); stdin.resume(); stdin.setEncoding('hex'); stdin.on('data', key => { if (key === KEYS.ENTER) { resolve(); } else if ( [KEYS.ESCAPE, KEYS.CONTROL_C, KEYS.CONTROL_D].indexOf(key) !== -1) { reject(); } }); } else { resolve(); } }); };