Skip to content

Commit

Permalink
Support autolinking when downloading FontAwesome5 Pro fonts (#1166)
Browse files Browse the repository at this point in the history
  • Loading branch information
hampustagerud committed Jun 8, 2020
1 parent b4fb744 commit 2093210
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions FONTAWESOME5.md
Expand Up @@ -85,8 +85,10 @@ Not passing a style will result in Regular style.
You need your FontAwesome npm token which can be obtained by logging into your
account and then access the `Services` tab.

Run `./node_modules/.bin/fa5-upgrade` and enter the token when asked to in order to
upgrade to the Pro version.
Run `yarn fa5-upgrade` or `./node_modules/.bin/fa5-upgrade` and enter the token
when asked to in order to upgrade to the Pro version. It will install the fonts
in your repo in the `assets/fonts` directory but the folder can be customized by
setting it when executing the command: `yarn fa5-upgrade [destination]`.

## Manually

Expand Down
19 changes: 12 additions & 7 deletions bin/fa5-upgrade.sh
Expand Up @@ -2,7 +2,7 @@

TEMP_DIR_PATH=""
FONTAWESOME_PRO_DIR_NAME=""
DEST_DIR_PATH="assets/fonts"
DEST_DIR_PATH=${1:-"assets/fonts"}
PROJECT_NAME="react-native-vector-icons"
FONT_NAME="Font Awesome Pro"

Expand Down Expand Up @@ -84,14 +84,19 @@ copy_ttf_fonts_to_dest_dir()
fi
}

modify_package_json()
create_rn_config()
{
/usr/bin/env node "./node_modules/$PROJECT_NAME/bin/add-font-assets.js"
if [ -f "./react-native.config.js" ]; then
echo "You already have a react-native-config.js file, make sure you have the new fonts added to the dependencies!";
return 1;
else
echo "module.exports = { assets: [ '${DEST_DIR_PATH}' ] };" > react-native.config.js;
fi
}

react_native_link_project()
{
react-native link "$PROJECT_NAME"
react-native link
}

if setup_npm_config; then
Expand Down Expand Up @@ -120,10 +125,10 @@ else
exit 1;
fi

if modify_package_json; then
echo "[SUCCESS] Modified package.json file";
if create_rn_config; then
echo "[SUCCESS] Created react-native.config.js";
else
exit 1;
echo "[INFO] Didn't create react-native.config.js, it already exists. Make sure '${DEST_DIR_PATH}' is part of the 'assets' array!";
fi

if react_native_link_project; then
Expand Down

0 comments on commit 2093210

Please sign in to comment.