punchcutter 2.0.4 → 2.0.6

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/buildGlyph.js CHANGED
@@ -3,16 +3,14 @@ const _ = require('lodash');
3
3
  const chalk = require('chalk');
4
4
  const DirectoryColorfy = require('directory-colorfy');
5
5
  const fs = require('fs-extra');
6
+ const globby = require('globby');
6
7
  const path = require('path');
7
8
  const Promise = require('bluebird');
8
9
  const loadFiles = require('./loadFiles');
9
- const multiGlob = require('./multiGlob');
10
10
  const svg2pngMin = require('./svg2pngMin');
11
11
  const svgMin = require('./svgMin');
12
12
  const {PNG, SVG} = require('./constants');
13
13
 
14
- Promise.promisifyAll(fs);
15
-
16
14
  /**
17
15
  *
18
16
  * @param {Object} config
@@ -41,20 +39,18 @@ module.exports = function (config) {
41
39
  // Delete temp directories.
42
40
  return (
43
41
  Promise.mapSeries([tempDir1, tempDir2], function (file) {
44
- return fs.removeAsync(file);
42
+ return fs.remove(file);
45
43
  })
46
44
  .then(function () {
47
45
  const dirs = [tempDir1, tempDir2].concat(svgBuildsDist, pngBuildsDist);
48
46
 
49
47
  // Create temp and destination directories.
50
48
  return Promise.mapSeries(dirs, function (dir) {
51
- return fs.mkdirpAsync(dir);
49
+ return fs.mkdirp(dir);
52
50
  });
53
51
  })
54
52
  // Find source files.
55
- .then(function () {
56
- return multiGlob(config.src);
57
- })
53
+ .then(() => globby(config.src))
58
54
  .then(function (files) {
59
55
  srcFiles = files;
60
56
 
@@ -68,7 +64,7 @@ module.exports = function (config) {
68
64
  svgDistDirs.push(svgDistDir);
69
65
 
70
66
  return fs
71
- .mkdirpAsync(svgDistDir)
67
+ .mkdirp(svgDistDir)
72
68
  .then(function () {
73
69
  return Promise.mapSeries(srcFiles, function (file) {
74
70
  // Add colors to filename for DirectoryColorfy.
@@ -85,7 +81,7 @@ module.exports = function (config) {
85
81
  )} > ${chalk.cyan(basename)} > ${chalk.cyan(color.name)}`
86
82
  );
87
83
 
88
- return fs.copyAsync(file, copy);
84
+ return fs.copy(file, copy);
89
85
  });
90
86
  })
91
87
  .then(function () {
@@ -101,7 +97,7 @@ module.exports = function (config) {
101
97
  })
102
98
  .then(function (files) {
103
99
  return Promise.mapSeries(files, function (file) {
104
- return fs.writeFileAsync(file.path, file.data, 'utf-8');
100
+ return fs.writeFile(file.path, file.data, 'utf-8');
105
101
  });
106
102
  })
107
103
  .then(function () {
@@ -124,7 +120,7 @@ module.exports = function (config) {
124
120
  );
125
121
  const distPath = path.resolve(svgDistDir, basename + '.svg');
126
122
 
127
- return fs.renameAsync(srcPath, distPath);
123
+ return fs.rename(srcPath, distPath);
128
124
  });
129
125
  });
130
126
  });
@@ -144,13 +140,13 @@ module.exports = function (config) {
144
140
  );
145
141
 
146
142
  return fs
147
- .readFileAsync(file, 'utf-8')
143
+ .readFile(file, 'utf-8')
148
144
  .then(function (data) {
149
145
  // Minify SVG.
150
146
  return svgMin(data);
151
147
  })
152
148
  .then(function (data) {
153
- return fs.writeFileAsync(svgDistPath, data, 'utf-8');
149
+ return fs.writeFile(svgDistPath, data, 'utf-8');
154
150
  })
155
151
  .then(function () {
156
152
  if (pngBuilds.length) {
@@ -172,7 +168,7 @@ module.exports = function (config) {
172
168
  });
173
169
  const base = path.resolve(svgDistDirs[0], '..');
174
170
 
175
- return multiGlob(src).then(function (files) {
171
+ return globby(src).then(function (files) {
176
172
  return Promise.mapSeries(pngBuilds, function (pngBuild, i) {
177
173
  console.log(
178
174
  `Building PNG glyphs [${i + 1}/${
@@ -209,7 +205,7 @@ module.exports = function (config) {
209
205
 
210
206
  // Clean up.
211
207
  return Promise.mapSeries(dirs, function (file) {
212
- return fs.removeAsync(file);
208
+ return fs.remove(file);
213
209
  });
214
210
  })
215
211
  );
@@ -8,8 +8,6 @@ const Promise = require('bluebird');
8
8
  const loadFiles = require('./loadFiles');
9
9
  const svgMin = require('./svgMin');
10
10
 
11
- Promise.promisifyAll(fs);
12
-
13
11
  /**
14
12
  *
15
13
  * @param {Object} config
@@ -55,8 +53,8 @@ module.exports = function (config) {
55
53
  const distPath = path.resolve(config.build.dist, config.name + '.js');
56
54
  const distDir = path.dirname(distPath);
57
55
 
58
- return fs.mkdirpAsync(distDir).then(function () {
59
- return fs.writeFileAsync(distPath, data, 'utf-8');
56
+ return fs.mkdirp(distDir).then(function () {
57
+ return fs.writeFile(distPath, data, 'utf-8');
60
58
  });
61
59
  });
62
60
  };
@@ -4,17 +4,15 @@ const autoprefixer = require('autoprefixer');
4
4
  const chalk = require('chalk');
5
5
  const crypto = require('crypto');
6
6
  const fs = require('fs-extra');
7
+ const globby = require('globby');
7
8
  const path = require('path');
8
9
  const postcss = require('postcss');
9
10
  const Promise = require('bluebird');
10
11
  const sass = require('node-sass');
11
12
  const Spritesmith = require('spritesmith');
12
13
  const nunjucks = require('nunjucks');
13
- const multiGlob = require('./multiGlob');
14
14
  const packageJson = require('../package.json');
15
15
 
16
- Promise.promisifyAll(fs);
17
-
18
16
  const md5 = crypto.createHash('md5');
19
17
 
20
18
  /**
@@ -27,7 +25,7 @@ module.exports = function (config) {
27
25
  md5.update(JSON.stringify(config));
28
26
 
29
27
  return Promise.mapSeries(config.build.rules, (rule) =>
30
- multiGlob(rule.src).then((glyphs) =>
28
+ globby(rule.src).then((glyphs) =>
31
29
  Promise.resolve(
32
30
  _.assign({}, rule, {
33
31
  src: glyphs.map((glyph) => ({
@@ -75,11 +73,9 @@ module.exports = function (config) {
75
73
 
76
74
  md5.update(result.image);
77
75
 
78
- fs.outputFileAsync(file, result.image, 'binary').then(
79
- function () {
80
- resolve(sprite);
81
- }
82
- );
76
+ fs.outputFile(file, result.image, 'binary').then(function () {
77
+ resolve(sprite);
78
+ });
83
79
  }
84
80
  });
85
81
  })
@@ -94,10 +90,8 @@ module.exports = function (config) {
94
90
 
95
91
  // Build stylesheet data.
96
92
  const {sprite: baselineSprite} = rules[0];
97
- const {
98
- width: spriteWidth,
99
- height: spriteHeight
100
- } = baselineSprite.properties;
93
+ const {width: spriteWidth, height: spriteHeight} =
94
+ baselineSprite.properties;
101
95
  const baselineRuleGlyphs = _.values(baselineSprite.coordinates);
102
96
  const {width: glyphWidth, height: glyphHeight} = baselineRuleGlyphs.length
103
97
  ? baselineRuleGlyphs[0]
@@ -137,10 +131,7 @@ module.exports = function (config) {
137
131
  }));
138
132
 
139
133
  return fs
140
- .readFileAsync(
141
- path.join(__dirname, '../src/png-sprite.scss.njk'),
142
- 'utf8'
143
- )
134
+ .readFile(path.join(__dirname, '../src/png-sprite.scss.njk'), 'utf-8')
144
135
  .then((data) =>
145
136
  Promise.resolve(
146
137
  nunjucks.renderString(data, {
@@ -170,11 +161,11 @@ module.exports = function (config) {
170
161
  }
171
162
  )
172
163
  .then((result) =>
173
- fs.outputFileAsync(cssPath, result.css, 'utf8')
164
+ fs.outputFile(cssPath, result.css, 'utf-8')
174
165
  );
175
166
 
176
167
  case 'scss':
177
- return fs.outputFileAsync(scssPath, data, 'utf8');
168
+ return fs.outputFile(scssPath, data, 'utf-8');
178
169
  }
179
170
 
180
171
  return Promise.reject(
@@ -199,14 +190,11 @@ module.exports = function (config) {
199
190
  };
200
191
 
201
192
  return fs
202
- .readFileAsync(
203
- path.join(__dirname, '../src/png-sprite.html.njk'),
204
- 'utf8'
205
- )
193
+ .readFile(path.join(__dirname, '../src/png-sprite.html.njk'), 'utf-8')
206
194
  .then((data) =>
207
195
  Promise.resolve(nunjucks.renderString(data, htmlData))
208
196
  )
209
- .then((data) => fs.outputFileAsync(htmlPath, data, 'utf8'));
197
+ .then((data) => fs.outputFile(htmlPath, data, 'utf-8'));
210
198
  }
211
199
 
212
200
  return Promise.resolve();
@@ -9,8 +9,6 @@ const svgstore = require('svgstore');
9
9
  const loadFiles = require('./loadFiles');
10
10
  const svgMin = require('./svgMin');
11
11
 
12
- Promise.promisifyAll(fs);
13
-
14
12
  /**
15
13
  *
16
14
  * @param {Object} config
@@ -52,8 +50,8 @@ module.exports = function (config) {
52
50
  const distPath = path.resolve(build.dist, config.name + '.svg');
53
51
  const distDir = path.dirname(distPath);
54
52
 
55
- return fs.mkdirpAsync(distDir).then(function () {
56
- return fs.writeFileAsync(distPath, data, 'utf-8');
53
+ return fs.mkdirp(distDir).then(function () {
54
+ return fs.writeFile(distPath, data, 'utf-8');
57
55
  });
58
56
  });
59
57
  });
@@ -1,9 +1,9 @@
1
1
  /* eslint no-console: 0 */
2
2
  const _ = require('lodash');
3
3
  const chalk = require('chalk');
4
+ const globby = require('globby');
4
5
  const Promise = require('bluebird');
5
6
  const webfont = require('grunt-webfont');
6
- const multiGlob = require('./multiGlob');
7
7
 
8
8
  /**
9
9
  *
@@ -13,7 +13,7 @@ const multiGlob = require('./multiGlob');
13
13
  module.exports = function (config) {
14
14
  console.log(`Building web font: ${chalk.cyan(config.name)}`);
15
15
 
16
- return multiGlob(config.src).then(function (files) {
16
+ return globby(config.src).then(function (files) {
17
17
  return new Promise(function (resolve, reject) {
18
18
  let task;
19
19
 
package/lib/constants.js CHANGED
@@ -5,7 +5,6 @@ const SVG_SPRITE = 'svg-sprite';
5
5
  const WEB_FONT = 'web-font';
6
6
  const PNG = 'png';
7
7
  const SVG = 'svg';
8
- const EOT = 'eot';
9
8
  const WOFF2 = 'woff2';
10
9
  const WOFF = 'woff';
11
10
  const TTF = 'ttf';
@@ -18,7 +17,6 @@ module.exports = {
18
17
  WEB_FONT,
19
18
  PNG,
20
19
  SVG,
21
- EOT,
22
20
  WOFF,
23
21
  WOFF2,
24
22
  TTF
package/lib/loadFiles.js CHANGED
@@ -1,9 +1,7 @@
1
1
  const _ = require('lodash');
2
2
  const fs = require('fs-extra');
3
+ const globby = require('globby');
3
4
  const Promise = require('bluebird');
4
- const multiGlob = require('./multiGlob');
5
-
6
- Promise.promisifyAll(fs);
7
5
 
8
6
  /**
9
7
  *
@@ -11,14 +9,14 @@ Promise.promisifyAll(fs);
11
9
  * @returns {Promise}
12
10
  */
13
11
  module.exports = function (src) {
14
- return multiGlob(src).then(function (matches) {
12
+ return globby(src).then(function (matches) {
15
13
  const files = _.map(matches, function (file) {
16
14
  return {path: file};
17
15
  });
18
16
 
19
17
  return Promise.mapSeries(files, function (file) {
20
18
  return Promise.props(
21
- _.assign(file, {data: fs.readFileAsync(file.path, 'utf-8')})
19
+ _.assign(file, {data: fs.readFile(file.path, 'utf-8')})
22
20
  );
23
21
  });
24
22
  });
package/lib/svg2pngMin.js CHANGED
@@ -5,8 +5,6 @@ const path = require('path');
5
5
  const Promise = require('bluebird');
6
6
  const sharp = require('sharp');
7
7
 
8
- Promise.promisifyAll(fs);
9
-
10
8
  /**
11
9
  *
12
10
  * @param {string} src - Soure file path
@@ -24,8 +22,8 @@ module.exports = function (src, destDir, scale, suffix) {
24
22
  );
25
23
 
26
24
  return fs
27
- .mkdirpAsync(destDir)
28
- .then(() => fs.readFileAsync(src, 'utf-8'))
25
+ .mkdirp(destDir)
26
+ .then(() => fs.readFile(src, 'utf-8'))
29
27
  .then((data) => {
30
28
  let resize;
31
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "punchcutter",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Build fonts",
5
5
  "main": "lib/punchcutter.js",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "url": "https://github.com/netbek/punchcutter/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/core": "7.20.2",
24
+ "@babel/core": "7.20.12",
25
25
  "@babel/eslint-parser": "7.19.1",
26
26
  "autoprefixer": "10.4.13",
27
27
  "babel-loader": "8.3.0",
@@ -31,41 +31,39 @@
31
31
  "chalk": "4.1.2",
32
32
  "cheerio": "0.22.0",
33
33
  "directory-colorfy": "https://github.com/netbek/directory-colorfy.git#netbek-jsdom-9",
34
- "eslint": "8.26.0",
34
+ "eslint": "8.32.0",
35
35
  "eslint-config-airbnb": "19.0.4",
36
- "eslint-config-prettier": "8.5.0",
36
+ "eslint-config-prettier": "8.6.0",
37
37
  "eslint-plugin-babel": "5.3.1",
38
38
  "eslint-plugin-dollar-sign": "1.0.2",
39
39
  "eslint-plugin-html": "6.2.0",
40
- "eslint-plugin-import": "2.26.0",
41
- "eslint-plugin-jsdoc": "39.6.2",
42
- "eslint-plugin-jsx-a11y": "6.6.1",
40
+ "eslint-plugin-import": "2.27.5",
41
+ "eslint-plugin-jsdoc": "39.6.9",
42
+ "eslint-plugin-jsx-a11y": "6.7.1",
43
43
  "eslint-plugin-markdown": "2.2.1",
44
44
  "eslint-plugin-prettier": "4.2.1",
45
- "eslint-plugin-react": "7.31.10",
45
+ "eslint-plugin-react": "7.32.1",
46
46
  "eslint-plugin-react-hooks": "4.6.0",
47
47
  "fs-extra": "10.1.0",
48
- "glob": "7.2.3",
49
- "glob-promise": "4.2.2",
48
+ "globby": "9.2.0",
50
49
  "grunt": "1.5.3",
51
50
  "grunt-webfont": "git+https://github.com/netbek/grunt-webfont.git#netbek-logger-option",
52
51
  "lodash": "4.17.21",
53
52
  "lodash-webpack-plugin": "0.11.6",
54
53
  "node-sass": "7.0.3",
55
54
  "nunjucks": "3.2.3",
56
- "postcss": "8.4.18",
57
- "prettier": "2.7.1",
55
+ "postcss": "8.4.21",
56
+ "prettier": "2.8.3",
58
57
  "replace-ext": "2.0.0",
59
- "sharp": "0.31.2",
58
+ "sharp": "0.31.3",
60
59
  "spritesmith": "3.4.0",
61
60
  "svgo": "2.8.0",
62
61
  "svgstore": "3.0.1",
63
62
  "webpack": "4.46.0"
64
63
  },
65
64
  "devDependencies": {
66
- "chai": "4.3.6",
65
+ "chai": "4.3.7",
67
66
  "chai-as-promised": "7.1.1",
68
- "glob-promise": "4.2.2",
69
67
  "mocha": "9.2.2"
70
68
  }
71
69
  }
package/test/index.js CHANGED
@@ -3,8 +3,8 @@ const {assert} = chai;
3
3
  const chaiAsPromised = require('chai-as-promised');
4
4
  chai.use(chaiAsPromised);
5
5
  const fs = require('fs-extra');
6
+ const globby = require('globby');
6
7
  const Promise = require('bluebird');
7
- const multiGlob = require('../lib/multiGlob');
8
8
  const {
9
9
  build,
10
10
  GLYPH,
@@ -14,13 +14,10 @@ const {
14
14
  WEB_FONT,
15
15
  PNG,
16
16
  SVG,
17
- EOT,
18
17
  WOFF,
19
18
  TTF
20
19
  } = require('..');
21
20
 
22
- Promise.promisifyAll(fs);
23
-
24
21
  describe('Punchcutter', function () {
25
22
  const testDir = __dirname.substring(process.cwd().length + 1) + '/';
26
23
 
@@ -65,14 +62,14 @@ describe('Punchcutter', function () {
65
62
  font: {
66
63
  dist: testDir + 'data/dist/poly/font/'
67
64
  },
68
- order: [EOT, WOFF, TTF],
65
+ order: [WOFF, TTF],
69
66
  stylesheets: ['scss'],
70
67
  syntax: 'bem',
71
68
  templateOptions: {
72
69
  baseClass: 'poly',
73
70
  classPrefix: 'poly--'
74
71
  },
75
- types: [EOT, WOFF, TTF]
72
+ types: [WOFF, TTF]
76
73
  },
77
74
  {
78
75
  type: GLYPH,
@@ -139,7 +136,7 @@ describe('Punchcutter', function () {
139
136
 
140
137
  const setup = function (done) {
141
138
  // Delete test output.
142
- fs.removeAsync(testDir + 'data/dist/').then(function () {
139
+ fs.remove(testDir + 'data/dist/').then(function () {
143
140
  done();
144
141
  });
145
142
  };
@@ -153,7 +150,7 @@ describe('Punchcutter', function () {
153
150
 
154
151
  const actual = () =>
155
152
  Promise.mapSeries(config.fonts, (font) => build(font))
156
- .then(() => multiGlob([testDir + 'data/dist/**/*'], {nodir: true}))
153
+ .then(() => globby([testDir + 'data/dist/**/*'], {onlyFiles: true}))
157
154
  .then((files) => Promise.resolve(files.sort()));
158
155
 
159
156
  const expected = [
@@ -161,7 +158,6 @@ describe('Punchcutter', function () {
161
158
  testDir + 'data/dist/mono/glyph/svg/eye.svg',
162
159
  testDir + 'data/dist/mono/svg-sprite/mono.svg',
163
160
  testDir + 'data/dist/poly/font/_poly.scss',
164
- testDir + 'data/dist/poly/font/poly.eot',
165
161
  testDir + 'data/dist/poly/font/poly.ttf',
166
162
  testDir + 'data/dist/poly/font/poly.woff',
167
163
  testDir + 'data/dist/poly/glyph/png/@1x/blue/erlenmeyer-flask.png',
package/lib/multiGlob.js DELETED
@@ -1,23 +0,0 @@
1
- const fs = require('fs-extra');
2
- const globPromise = require('glob-promise');
3
- const Promise = require('bluebird');
4
-
5
- Promise.promisifyAll(fs);
6
-
7
- /**
8
- *
9
- * @param {Array} patterns
10
- * @param {Object} options
11
- * @returns {Promise}
12
- */
13
- module.exports = function (patterns, options) {
14
- let matches = [];
15
-
16
- return Promise.mapSeries(patterns, function (pattern) {
17
- return globPromise(pattern, options).then(function (files) {
18
- matches = matches.concat(files);
19
- });
20
- }).then(function () {
21
- return Promise.resolve(matches);
22
- });
23
- };