|
| 1 | +/** |
| 2 | + * macOSNotifJS: A simple Javascript plugin to create simulated macOS notifications on your website. |
| 3 | + * <https://github.com/MattIPv4/macOSNotifJS/> |
| 4 | + * Copyright (C) 2019 Matt Cowley (MattIPv4) (me@mattcowley.co.uk) |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Affero General Public License as published |
| 8 | + * by the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * You should have received a copy of the GNU Affero General Public License |
| 15 | + * along with this program. If not, please see |
| 16 | + * <https://github.com/MattIPv4/macOSNotifJS/blob/master/LICENSE> or <http://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +const chalk = require("chalk"); |
1 | 20 | const Fontmin = require("fontmin");
|
2 | 21 |
|
3 |
| -const fonts = new Fontmin() |
4 |
| - .src("src/fonts/src/*.otf") |
5 |
| - .use(Fontmin.otf2ttf()) |
6 |
| - .use(Fontmin.ttf2eot()) |
7 |
| - .use(Fontmin.ttf2woff({ deflate: true })) |
8 |
| - .dest("src/fonts/build"); |
| 22 | +const buildFonts = () => { |
| 23 | + return new Promise((resolve, reject) => { |
| 24 | + const fonts = new Fontmin() |
| 25 | + .src("src/fonts/src/*.otf") |
| 26 | + .use(Fontmin.otf2ttf()) |
| 27 | + .use(Fontmin.ttf2eot()) |
| 28 | + .use(Fontmin.ttf2woff({ deflate: true })) |
| 29 | + .dest("src/fonts/build"); |
9 | 30 |
|
10 |
| -fonts.run((err, files) => { |
11 |
| - if (err) throw err; |
12 |
| - files.forEach(file => { |
13 |
| - console.info("\x1b[36m%s\x1b[0m", "\n" + file.history.slice(-1)[0]); |
14 |
| - console.log("\t" + file.history.slice(-1)[0].replace(/^.*[\\/]/, "")); |
| 31 | + fonts.run((err, files) => { |
| 32 | + if (err) { |
| 33 | + console.error(chalk.red.bold("Failed to build fonts")); |
| 34 | + reject(); |
| 35 | + throw err; |
| 36 | + } |
| 37 | + files.forEach(file => { |
| 38 | + console.info(chalk.cyan("\n" + file.history.slice(-1)[0])); |
| 39 | + console.log("\t" + file.history.slice(-1)[0].replace(/^.*[\\/]/, "")); |
| 40 | + }); |
| 41 | + console.log(chalk.green("\nSuccessfully built " + files.length.toString() + " font files.")); |
| 42 | + resolve(); |
| 43 | + }); |
15 | 44 | });
|
16 |
| - console.log("\x1b[32m%s\x1b[0m", "\nSuccessfully built " + files.length.toString() + " font files."); |
17 |
| -}); |
| 45 | +}; |
| 46 | + |
| 47 | +// Run |
| 48 | +buildFonts(); |
0 commit comments