getCacheDirectory.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _os() {
  7. const data = require('os');
  8. _os = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function path() {
  14. const data = _interopRequireWildcard(require('path'));
  15. path = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _jestUtil() {
  21. const data = require('jest-util');
  22. _jestUtil = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _getRequireWildcardCache() {
  28. if (typeof WeakMap !== 'function') return null;
  29. var cache = new WeakMap();
  30. _getRequireWildcardCache = function () {
  31. return cache;
  32. };
  33. return cache;
  34. }
  35. function _interopRequireWildcard(obj) {
  36. if (obj && obj.__esModule) {
  37. return obj;
  38. }
  39. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  40. return {default: obj};
  41. }
  42. var cache = _getRequireWildcardCache();
  43. if (cache && cache.has(obj)) {
  44. return cache.get(obj);
  45. }
  46. var newObj = {};
  47. var hasPropertyDescriptor =
  48. Object.defineProperty && Object.getOwnPropertyDescriptor;
  49. for (var key in obj) {
  50. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  51. var desc = hasPropertyDescriptor
  52. ? Object.getOwnPropertyDescriptor(obj, key)
  53. : null;
  54. if (desc && (desc.get || desc.set)) {
  55. Object.defineProperty(newObj, key, desc);
  56. } else {
  57. newObj[key] = obj[key];
  58. }
  59. }
  60. }
  61. newObj.default = obj;
  62. if (cache) {
  63. cache.set(obj, newObj);
  64. }
  65. return newObj;
  66. }
  67. /**
  68. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  69. *
  70. * This source code is licensed under the MIT license found in the
  71. * LICENSE file in the root directory of this source tree.
  72. */
  73. const getCacheDirectory = () => {
  74. const {getuid} = process;
  75. const tmpdirPath = path().join(
  76. (0, _jestUtil().tryRealpath)((0, _os().tmpdir)()),
  77. 'jest'
  78. );
  79. if (getuid == null) {
  80. return tmpdirPath;
  81. } else {
  82. // On some platforms tmpdir() is `/tmp`, causing conflicts between different
  83. // users and permission issues. Adding an additional subdivision by UID can
  84. // help.
  85. return `${tmpdirPath}_${getuid.call(process).toString(36)}`;
  86. }
  87. };
  88. var _default = getCacheDirectory;
  89. exports.default = _default;