createDirectory.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = createDirectory;
  6. function fs() {
  7. const data = _interopRequireWildcard(require('graceful-fs'));
  8. fs = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _getRequireWildcardCache(nodeInterop) {
  14. if (typeof WeakMap !== 'function') return null;
  15. var cacheBabelInterop = new WeakMap();
  16. var cacheNodeInterop = new WeakMap();
  17. return (_getRequireWildcardCache = function (nodeInterop) {
  18. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  19. })(nodeInterop);
  20. }
  21. function _interopRequireWildcard(obj, nodeInterop) {
  22. if (!nodeInterop && obj && obj.__esModule) {
  23. return obj;
  24. }
  25. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  26. return {default: obj};
  27. }
  28. var cache = _getRequireWildcardCache(nodeInterop);
  29. if (cache && cache.has(obj)) {
  30. return cache.get(obj);
  31. }
  32. var newObj = {};
  33. var hasPropertyDescriptor =
  34. Object.defineProperty && Object.getOwnPropertyDescriptor;
  35. for (var key in obj) {
  36. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  37. var desc = hasPropertyDescriptor
  38. ? Object.getOwnPropertyDescriptor(obj, key)
  39. : null;
  40. if (desc && (desc.get || desc.set)) {
  41. Object.defineProperty(newObj, key, desc);
  42. } else {
  43. newObj[key] = obj[key];
  44. }
  45. }
  46. }
  47. newObj.default = obj;
  48. if (cache) {
  49. cache.set(obj, newObj);
  50. }
  51. return newObj;
  52. }
  53. /**
  54. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  55. *
  56. * This source code is licensed under the MIT license found in the
  57. * LICENSE file in the root directory of this source tree.
  58. */
  59. function createDirectory(path) {
  60. try {
  61. fs().mkdirSync(path, {
  62. recursive: true
  63. });
  64. } catch (e) {
  65. if (e.code !== 'EEXIST') {
  66. throw e;
  67. }
  68. }
  69. }