From c160ba3b846ca647db79523c39f5a9f8adf63893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Sat, 4 Jun 2016 16:55:21 -0400 Subject: [PATCH] Add a build script for Font Awesome --- package.json | 3 ++- scripts/build-fontawesome.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 scripts/build-fontawesome.js diff --git a/package.json b/package.json index 09a02a67..7b254d8a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "scripts": { "start": "node index", "build": "npm run build:font-awesome && npm run build:grunt && npm run build:handlebars", - "build:font-awesome": "mkdir -p client/fonts && cp node_modules/font-awesome/fonts/fontawesome-webfont.* client/fonts", + "build:font-awesome": "node scripts/build-fontawesome.js", "build:grunt": "grunt", "build:handlebars": "handlebars client/views/ -e tpl -f client/js/lounge.templates.js", "test": "(npm run test:mocha || true) && npm run lint", @@ -43,6 +43,7 @@ "commander": "2.9.0", "event-stream": "3.3.2", "express": "4.13.4", + "fs-extra": "0.30.0", "irc-framework": "2.0.0", "lodash": "4.11.2", "mkdirp": "0.5.1", diff --git a/scripts/build-fontawesome.js b/scripts/build-fontawesome.js new file mode 100644 index 00000000..a38a26db --- /dev/null +++ b/scripts/build-fontawesome.js @@ -0,0 +1,29 @@ +"use strict"; + +var fs = require("fs-extra"); + +var srcDir = "./node_modules/font-awesome/fonts/"; +var destDir = "./client/fonts/"; +var fonts = [ + "fontawesome-webfont.eot", + "fontawesome-webfont.svg", + "fontawesome-webfont.ttf", + "fontawesome-webfont.woff", + "fontawesome-webfont.woff2" +]; + +fs.ensureDir(destDir, function (err) { + if (err) { + console.error(err); + } + + fonts.forEach(function (font) { + fs.copy(srcDir + font, destDir + font, function (err) { + if (err) { + console.error(err); + } else { + console.log(font + " successfully installed."); + } + }); + }); +});