getCacheDirectory.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _path() {
  7. const data = _interopRequireDefault(require('path'));
  8. _path = function _path() {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _os() {
  14. const data = _interopRequireDefault(require('os'));
  15. _os = function _os() {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _realpathNative() {
  21. const data = require('realpath-native');
  22. _realpathNative = function _realpathNative() {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _interopRequireDefault(obj) {
  28. return obj && obj.__esModule ? obj : {default: obj};
  29. }
  30. /**
  31. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  32. *
  33. * This source code is licensed under the MIT license found in the
  34. * LICENSE file in the root directory of this source tree.
  35. */
  36. const getCacheDirectory = () => {
  37. const _process = process,
  38. getuid = _process.getuid;
  39. const tmpdir = _path().default.join(
  40. (0, _realpathNative().sync)(_os().default.tmpdir()),
  41. 'jest'
  42. );
  43. if (getuid == null) {
  44. return tmpdir;
  45. } else {
  46. // On some platforms tmpdir() is `/tmp`, causing conflicts between different
  47. // users and permission issues. Adding an additional subdivision by UID can
  48. // help.
  49. return `${tmpdir}_${getuid.call(process).toString(36)}`;
  50. }
  51. };
  52. var _default = getCacheDirectory;
  53. exports.default = _default;