getCacheDirectory.js 801 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. /**
  6. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  7. *
  8. * This source code is licensed under the MIT license found in the
  9. * LICENSE file in the root directory of this source tree.
  10. *
  11. *
  12. */
  13. const path = require('path');
  14. const os = require('os');
  15. const getCacheDirectory = () => {
  16. var _process = process;
  17. const getuid = _process.getuid;
  18. if (getuid == null) {
  19. return path.join(os.tmpdir(), 'jest');
  20. }
  21. // On some platforms tmpdir() is `/tmp`, causing conflicts between different
  22. // users and permission issues. Adding an additional subdivision by UID can
  23. // help.
  24. return path.join(os.tmpdir(), 'jest_' + getuid.call(process).toString(36));
  25. };
  26. exports.default = getCacheDirectory;