Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native link and react-native unlink update. #14801

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions local-cli/link/android/unlinkAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};
22 changes: 14 additions & 8 deletions local-cli/link/ios/copyAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
20 changes: 13 additions & 7 deletions local-cli/link/ios/unlinkAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down