punchcutter 1.0.41 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/svg2pngMin.js +7 -23
- package/package.json +2 -4
package/lib/svg2pngMin.js
CHANGED
|
@@ -2,10 +2,8 @@ const _ = require('lodash');
|
|
|
2
2
|
const cheerio = require('cheerio');
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const pngquant = require('pngquant');
|
|
6
5
|
const Promise = require('bluebird');
|
|
7
|
-
const
|
|
8
|
-
const svg2png = require('svg2png');
|
|
6
|
+
const sharp = require('sharp');
|
|
9
7
|
|
|
10
8
|
Promise.promisifyAll(fs);
|
|
11
9
|
|
|
@@ -27,10 +25,8 @@ module.exports = function (src, destDir, scale, suffix) {
|
|
|
27
25
|
|
|
28
26
|
return fs
|
|
29
27
|
.mkdirpAsync(destDir)
|
|
30
|
-
.then(
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
.then(function (data) {
|
|
28
|
+
.then(() => fs.readFileAsync(src, 'utf-8'))
|
|
29
|
+
.then((data) => {
|
|
34
30
|
let resize;
|
|
35
31
|
|
|
36
32
|
if (scale) {
|
|
@@ -54,24 +50,12 @@ module.exports = function (src, destDir, scale, suffix) {
|
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
// Convert SVG to PNG.
|
|
58
53
|
const buffer = Buffer.from(data, 'utf-8');
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return new Promise(function (resolve, reject) {
|
|
64
|
-
const writeStream = fs.createWriteStream(dest);
|
|
65
|
-
|
|
66
|
-
writeStream.on('close', function () {
|
|
67
|
-
resolve();
|
|
68
|
-
});
|
|
55
|
+
if (resize) {
|
|
56
|
+
return sharp(buffer).resize(resize).toFile(dest);
|
|
57
|
+
}
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
.createReadStream(buffer)
|
|
72
|
-
// Minify PNG.
|
|
73
|
-
.pipe(new pngquant([256]))
|
|
74
|
-
.pipe(writeStream);
|
|
75
|
-
});
|
|
59
|
+
return sharp(buffer).toFile(dest);
|
|
76
60
|
});
|
|
77
61
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "punchcutter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Build fonts",
|
|
5
5
|
"main": "lib/punchcutter.js",
|
|
6
6
|
"repository": {
|
|
@@ -53,13 +53,11 @@
|
|
|
53
53
|
"lodash-webpack-plugin": "0.11.6",
|
|
54
54
|
"node-sass": "7.0.1",
|
|
55
55
|
"nunjucks": "3.2.3",
|
|
56
|
-
"pngquant": "4.0.0",
|
|
57
56
|
"postcss": "8.4.14",
|
|
58
57
|
"prettier": "2.6.2",
|
|
59
58
|
"replace-ext": "2.0.0",
|
|
59
|
+
"sharp": "0.30.6",
|
|
60
60
|
"spritesmith": "3.4.0",
|
|
61
|
-
"streamifier": "0.1.1",
|
|
62
|
-
"svg2png": "4.1.1",
|
|
63
61
|
"svgo": "2.8.0",
|
|
64
62
|
"svgstore": "3.0.1",
|
|
65
63
|
"webpack": "4.46.0"
|