handleDeprecationWarnings.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _chalk() {
  7. const data = _interopRequireDefault(require('chalk'));
  8. _chalk = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _jestWatcher() {
  14. const data = require('jest-watcher');
  15. _jestWatcher = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _interopRequireDefault(obj) {
  21. return obj && obj.__esModule ? obj : {default: obj};
  22. }
  23. /**
  24. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  25. *
  26. * This source code is licensed under the MIT license found in the
  27. * LICENSE file in the root directory of this source tree.
  28. */
  29. var _default = (pipe, stdin = process.stdin) =>
  30. new Promise((resolve, reject) => {
  31. if (typeof stdin.setRawMode === 'function') {
  32. const messages = [
  33. _chalk().default.red('There are deprecation warnings.\n'),
  34. _chalk().default.dim(' \u203A Press ') +
  35. 'Enter' +
  36. _chalk().default.dim(' to continue.'),
  37. _chalk().default.dim(' \u203A Press ') +
  38. 'Esc' +
  39. _chalk().default.dim(' to exit.')
  40. ];
  41. pipe.write(messages.join('\n'));
  42. stdin.setRawMode(true);
  43. stdin.resume();
  44. stdin.setEncoding('utf8'); // this is a string since we set encoding above
  45. stdin.on('data', key => {
  46. if (key === _jestWatcher().KEYS.ENTER) {
  47. resolve();
  48. } else if (
  49. [
  50. _jestWatcher().KEYS.ESCAPE,
  51. _jestWatcher().KEYS.CONTROL_C,
  52. _jestWatcher().KEYS.CONTROL_D
  53. ].indexOf(key) !== -1
  54. ) {
  55. reject();
  56. }
  57. });
  58. } else {
  59. resolve();
  60. }
  61. });
  62. exports.default = _default;