UNPKG

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