Skip to content

Instantly share code, notes, and snippets.

View bartvanandel's full-sized avatar

Bart van Andel bartvanandel

View GitHub Profile
@bartvanandel
bartvanandel / README.md
Created October 3, 2022 11:56
Font download script, useful for using fonts as binary dependencies in your React Native app.

Introduction

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.

Solution

@bartvanandel
bartvanandel / yarn-sync.js
Last active November 15, 2022 22:41
Sync versions from yarn.lock back into package.json
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];