copyAssets.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = copyAssetsAndroid;
  6. function _fsExtra() {
  7. const data = _interopRequireDefault(require("fs-extra"));
  8. _fsExtra = 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 copyAssetsAndroid(files, project) {
  42. const assets = (0, _cliTools().groupFilesByType)(files);
  43. _cliTools().logger.debug(`Assets path: ${project.assetsPath}`);
  44. (assets.font || []).forEach(asset => {
  45. const fontsDir = _path().default.join(project.assetsPath, 'fonts');
  46. _cliTools().logger.debug(`Copying asset ${asset}`); // @todo: replace with fs.mkdirSync(path, {recursive}) + fs.copyFileSync
  47. // and get rid of fs-extra once we move to Node 10
  48. _fsExtra().default.copySync(asset, _path().default.join(fontsDir, _path().default.basename(asset)));
  49. });
  50. }
  51. //# sourceMappingURL=copyAssets.js.map