We were facing an issue where we need a font to be present at build time for a React Native app.
This font is essentially a binary dependency of our app, which we'd rather not add to our git repo
(in general, this is not the best practice). There exist packages that can provide certain fonts,
however these were either too unorganized for our taste, or didn't work with React-Native / Expo.
So, we searched for a solution to just download the fonts at npm install
time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
/** | |
* Removes matching outer quotes from a string. | |
* | |
* @param {string} text - String to unquote | |
* @returns {string} - Unquoted string | |
*/ | |
const unquote = text => /(["'])?(.*)\1/.exec(text)[2]; |