Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit 9a9fcf8

Browse files
committed
Update package.json & create proper pre-flight / build process
1 parent 17a9731 commit 9a9fcf8

File tree

5 files changed

+392
-42
lines changed

5 files changed

+392
-42
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"forceAllTransforms": true,
77
"useBuiltIns": "entry",
88
"exclude": ["transform-regenerator", "transform-async-to-generator"],
9-
"debug": true,
9+
"debug": false,
1010
"loose": true
1111
}
1212
]

fonts.js

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
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");
120
const Fontmin = require("fontmin");
221

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");
930

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+
});
1544
});
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

Comments
 (0)