Steven c1058b1e90 react-native link and react-native unlink update.
Summary:
1. Fix bug: Android project do not delete font files when run `react-native unlink`.
2. Add feature, link images to iOS project when run `react-native link`.
Closes https://github.com/facebook/react-native/pull/14801

Differential Revision: D5890051

Pulled By: hramos

fbshipit-source-id: 28223d181ac5ed51d70df29a56eb56b2cce9aecb
2017-09-22 05:46:38 -07:00

21 lines
644 B
JavaScript

const fs = require('fs-extra');
const path = require('path');
const groupFilesByType = require('../groupFilesByType');
/**
* Copies each file from an array of assets provided to targetPath directory
*
* For now, the only types of files that are handled are:
* - Fonts (otf, ttf) - copied to targetPath/fonts under original name
*/
module.exports = function unlinkAssetsAndroid(files, targetPath) {
const assets = groupFilesByType(files);
(assets.font || []).forEach((file) => {
const filePath = path.join(targetPath, 'fonts', path.basename(file));
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
}
});
};