diff --git a/local-cli/link/android/unlinkAssets.js b/local-cli/link/android/unlinkAssets.js index 79c51a1864515e..1cc0974d3e4e14 100644 --- a/local-cli/link/android/unlinkAssets.js +++ b/local-cli/link/android/unlinkAssets.js @@ -9,12 +9,12 @@ const groupFilesByType = require('../groupFilesByType'); * - Fonts (otf, ttf) - copied to targetPath/fonts under original name */ module.exports = function unlinkAssetsAndroid(files, targetPath) { - const grouped = groupFilesByType(files); + const assets = groupFilesByType(files); - grouped.font.forEach((file) => { - const filename = path.basename(file); - if (fs.existsSync(filename)) { - fs.unlinkSync(path.join(targetPath, 'fonts', filename)); + (assets.font || []).forEach((file) => { + const filePath = path.join(targetPath, 'fonts', path.basename(file)); + if (fs.existsSync(filePath)) { + fs.unlinkSync(filePath); } }); }; diff --git a/local-cli/link/ios/copyAssets.js b/local-cli/link/ios/copyAssets.js index cc271991fbf3e4..f8cd09198993a5 100644 --- a/local-cli/link/ios/copyAssets.js +++ b/local-cli/link/ios/copyAssets.js @@ -18,15 +18,21 @@ module.exports = function linkAssetsIOS(files, projectConfig) { createGroupWithMessage(project, 'Resources'); - const fonts = (assets.font || []) - .map(asset => - project.addResourceFile( - path.relative(projectConfig.sourceDir, asset), - { target: project.getFirstTarget().uuid } + function addResourceFile(f) { + return (f || []) + .map(asset => + project.addResourceFile( + path.relative(projectConfig.sourceDir, asset), + { target: project.getFirstTarget().uuid } + ) ) - ) - .filter(file => file) // xcode returns false if file is already there - .map(file => file.basename); + .filter(file => file) // xcode returns false if file is already there + .map(file => file.basename); + } + + addResourceFile(assets.image); + + const fonts = addResourceFile(assets.font); const existingFonts = (plist.UIAppFonts || []); const allFonts = [...existingFonts, ...fonts]; diff --git a/local-cli/link/ios/unlinkAssets.js b/local-cli/link/ios/unlinkAssets.js index ab31a1b9c7e625..70ec9b2116a6e7 100644 --- a/local-cli/link/ios/unlinkAssets.js +++ b/local-cli/link/ios/unlinkAssets.js @@ -30,14 +30,20 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) { ); } - const fonts = (assets.font || []) - .map(asset => - project.removeResourceFile( - path.relative(projectConfig.sourceDir, asset), - { target: project.getFirstTarget().uuid } + const removeResourceFile = function (f) { + (f || []) + .map(asset => + project.removeResourceFile( + path.relative(projectConfig.sourceDir, asset), + { target: project.getFirstTarget().uuid } + ) ) - ) - .map(file => file.basename); + .map(file => file.basename); + } + + removeResourceFile(assets.image); + + const fonts = removeResourceFile(assets.font); plist.UIAppFonts = difference(plist.UIAppFonts || [], fonts);