Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

enhanceUnexpectedTokenMessage.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = handlePotentialSyntaxError;
  6. exports.enhanceUnexpectedTokenMessage = enhanceUnexpectedTokenMessage;
  7. function _chalk() {
  8. const data = _interopRequireDefault(require('chalk'));
  9. _chalk = function () {
  10. return data;
  11. };
  12. return data;
  13. }
  14. function _interopRequireDefault(obj) {
  15. return obj && obj.__esModule ? obj : {default: obj};
  16. }
  17. /**
  18. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  19. *
  20. * This source code is licensed under the MIT license found in the
  21. * LICENSE file in the root directory of this source tree.
  22. */
  23. const DOT = ' \u2022 ';
  24. function handlePotentialSyntaxError(e) {
  25. if (e.codeFrame) {
  26. e.stack = e.message + '\n' + e.codeFrame;
  27. }
  28. if (
  29. // `instanceof` might come from the wrong context
  30. e.name === 'SyntaxError' &&
  31. !e.message.includes(' expected')
  32. ) {
  33. throw enhanceUnexpectedTokenMessage(e);
  34. }
  35. return e;
  36. }
  37. function enhanceUnexpectedTokenMessage(e) {
  38. e.stack =
  39. `${_chalk().default.bold.red('Jest encountered an unexpected token')}
  40. Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
  41. Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
  42. By default "node_modules" folder is ignored by transformers.
  43. Here's what you can do:
  44. ${DOT}If you are trying to use ECMAScript Modules, see ${_chalk().default.underline(
  45. 'https://jestjs.io/docs/ecmascript-modules'
  46. )} for how to enable it.
  47. ${DOT}If you are trying to use TypeScript, see ${_chalk().default.underline(
  48. 'https://jestjs.io/docs/getting-started#using-typescript'
  49. )}
  50. ${DOT}To have some of your "node_modules" files transformed, you can specify a custom ${_chalk().default.bold(
  51. '"transformIgnorePatterns"'
  52. )} in your config.
  53. ${DOT}If you need a custom transformation specify a ${_chalk().default.bold(
  54. '"transform"'
  55. )} option in your config.
  56. ${DOT}If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the ${_chalk().default.bold(
  57. '"moduleNameMapper"'
  58. )} config option.
  59. You'll find more details and examples of these config options in the docs:
  60. ${_chalk().default.cyan('https://jestjs.io/docs/configuration')}
  61. For information about custom transformations, see:
  62. ${_chalk().default.cyan('https://jestjs.io/docs/code-transformation')}
  63. ${_chalk().default.bold.red('Details:')}
  64. ` + e.stack;
  65. return e;
  66. }