unlinkAssets.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = unlinkAssetsAndroid;
  6. function _fs() {
  7. const data = _interopRequireDefault(require("fs"));
  8. _fs = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _path() {
  14. const data = _interopRequireDefault(require("path"));
  15. _path = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _cliTools() {
  21. const data = require("@react-native-community/cli-tools");
  22. _cliTools = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28. /**
  29. * Copyright (c) Facebook, Inc. and its affiliates.
  30. *
  31. * This source code is licensed under the MIT license found in the
  32. * LICENSE file in the root directory of this source tree.
  33. *
  34. */
  35. /**
  36. * Copies each file from an array of assets provided to targetPath directory
  37. *
  38. * For now, the only types of files that are handled are:
  39. * - Fonts (otf, ttf) - copied to targetPath/fonts under original name
  40. */
  41. function unlinkAssetsAndroid(files, project) {
  42. const assets = (0, _cliTools().groupFilesByType)(files);
  43. _cliTools().logger.debug(`Assets path: ${project.assetsPath}`);
  44. (assets.font || []).forEach(file => {
  45. const filePath = _path().default.join(project.assetsPath, 'fonts', _path().default.basename(file));
  46. if (_fs().default.existsSync(filePath)) {
  47. _cliTools().logger.debug(`Removing asset ${filePath}`);
  48. _fs().default.unlinkSync(filePath);
  49. }
  50. });
  51. }
  52. //# sourceMappingURL=unlinkAssets.js.map