Skip to content

Commit

Permalink
Chore: prepare 6.0.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krasnoyarov committed Nov 7, 2016
1 parent 25b29d4 commit 41c1d34
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 23 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 6.0.1 - 2016-11-07

- Fixed: add `error` event to `glyph` stream.
- Fixed: don't create `new Error` where this is not necessary.
- Chore: update a minimal version of `nunjucks` from `2.5.0` to `3.0.0`.
- Chore: update a minimal version of `eslint` from `3.4.0` to `3.9.1`.
- Chore: update a minimal version of `eslint-plugin-ava` from `3.0.0` to `4.0.0`.
- Chore: update a minimal version of `eslint-plugin-itgalaxy` from `23.0.0` to `25.0.0`.
- Chore: update a minimal version of `eslint-plugin-node` from `2.0.0` to `3.0.0`.
- Chore: update a minimal version of `eslint-plugin-promise` from `3.0.0` to `3.3.0`.
- Chore: update a minimal version of `eslint-plugin-react` from `6.2.0` to `6.5.0`.
- Tests: improve tests on bad examples.

# 6.0.0 - 2016-10-26

- Added: support `nodejs` `7`.
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webfont",
"version": "6.0.0",
"version": "6.0.1",
"description": "Generator of fonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2",
"license": "MIT",
"author": "itgalaxy <[email protected]>",
Expand Down Expand Up @@ -54,7 +54,7 @@
"meow": "^3.3.0",
"mkdirp": "^0.5.1",
"merge-deep": "^3.0.0",
"nunjucks": "^2.5.0",
"nunjucks": "^3.0.0",
"resolve-from": "2.0.0",
"svg2ttf": "^4.0.0",
"svgicons2svgfont": "^5.0.0",
Expand All @@ -71,15 +71,15 @@
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"coveralls": "^2.11.6",
"eslint": "^3.4.0",
"eslint-plugin-ava": "^3.0.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-itgalaxy": "^23.0.0",
"eslint": "^3.9.1",
"eslint-plugin-ava": "^4.0.0",
"eslint-plugin-import": "^2.1.0",
"eslint-plugin-itgalaxy": "^25.0.0",
"eslint-plugin-jsx-a11y": "^2.2.0",
"eslint-plugin-lodash": "^2.1.0",
"eslint-plugin-node": "^2.0.0",
"eslint-plugin-promise": "^3.0.0",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-node": "^3.0.0",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-react": "^6.5.0",
"eslint-plugin-unicorn": "^1.0.0",
"is-eot": "^1.0.0",
"is-svg": "^2.0.0",
Expand All @@ -92,7 +92,7 @@
"package-schema": "^1.0.0",
"remark-cli": "^2.0.0",
"remark-lint": "^5.0.0",
"remark-preset-lint-itgalaxy": "^2.0.0",
"remark-preset-lint-itgalaxy": "^3.0.0",
"rimraf": "^2.5.2"
},
"scripts": {
Expand Down
23 changes: 23 additions & 0 deletions src/__tests__/fixtures/bad-svg-icons/avatar-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/__tests__/fixtures/bad-svg-icons/avatar-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/__tests__/fixtures/bad-svg-icons/avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 40 additions & 11 deletions src/__tests__/standalone-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import test from 'ava';

const fixturesPath = path.join(__dirname, 'fixtures');

function logError(error) {
console.log(error.stack); // eslint-disable-line no-console
}

test('should throw error if `files` not passed', (t) => {
t.throws(standalone(), 'You must pass webfont a `files` glob');
});
Expand All @@ -36,7 +32,7 @@ test('should generated all fonts', (t) => {
t.true(isWoff2(result.woff2));

return result;
}).catch(logError);
});
});

test('should generated only `svg`, `ttf` and `eot` fonts', (t) => {
Expand All @@ -53,7 +49,7 @@ test('should generated only `svg`, `ttf` and `eot` fonts', (t) => {
t.true(typeof result.woff2 === 'undefined');

return result;
}).catch(logError);
});
});

test('should generated only `woff2` font', (t) => {
Expand All @@ -70,7 +66,7 @@ test('should generated only `woff2` font', (t) => {
t.true(isWoff2(result.woff2));

return result;
}).catch(logError);
});
});

// In future improve css tests on valid based on postcss
Expand All @@ -91,7 +87,7 @@ test('should generated only `woff and `woff2` fonts with css', (t) => {
t.true(result.css.length > 0); // eslint-disable-line ava/max-asserts

return result;
}).catch(logError);
});
});

test('should generated all fonts and css', (t) => {
Expand All @@ -110,7 +106,7 @@ test('should generated all fonts and css', (t) => {
t.true(result.css.length > 0); // eslint-disable-line ava/max-asserts

return result;
}).catch(logError);
});
});

test('should generated all fonts with `css` by passed template', (t) => {
Expand All @@ -129,7 +125,7 @@ test('should generated all fonts with `css` by passed template', (t) => {
t.is(result.css.slice(0, 21), '/* custom template */');

return result;
}).catch(logError);
});
});

test('should load config', (t) => {
Expand All @@ -146,7 +142,40 @@ test('should load config', (t) => {
t.true(isWoff2(result.woff2));

return result;
}).catch(logError);
});
});

test('should throw error on bad svg images - `Unclosed root tag`', (t) => {
t.plan(1);

return standalone({
configFile: `${fixturesPath}/configs/.webfontrc`,
files: `${fixturesPath}/bad-svg-icons/avatar.svg`
}).catch((error) => {
t.regex(error.message, /Unclosed root tag/);
});
});

test('should throw error on bad svg images - `Unterminated command at index`', (t) => {
t.plan(1);

return standalone({
configFile: `${fixturesPath}/configs/.webfontrc`,
files: `${fixturesPath}/bad-svg-icons/avatar-1.svg`
}).catch((error) => {
t.regex(error.message, /Unterminated command at index/);
});
});

test('should throw error on bad svg images - `Unexpected character "N"`', (t) => {
t.plan(1);

return standalone({
configFile: `${fixturesPath}/configs/.webfontrc`,
files: `${fixturesPath}/bad-svg-icons/avatar-2.svg`
}).catch((error) => {
t.regex(error.message, /Unexpected character "N"/);
});
});

test('should throw error of config file not found', (t) => {
Expand Down
7 changes: 5 additions & 2 deletions src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function svgIcons2svgFontFn(files, options, glyphs = []) {
normalize: options.normalize,
round: options.round
});

const metadataProvider = options.metadataProvider || defaultMetadataProvider({
prependUnicode: options.prependUnicode,
startUnicode: options.startUnicode
Expand All @@ -44,11 +45,13 @@ function svgIcons2svgFontFn(files, options, glyphs = []) {
(srcPath) => new Promise((resolve, reject) => {
metadataProvider(srcPath, (error, metadata) => {
if (error) {
return reject(new Error(error));
return reject(error);
}

const glyph = fs.createReadStream(srcPath);

glyph.on('error', (glyphError) => Promise.reject(glyphError));

glyph.metadata = metadata;
fontStream.write(glyph);

Expand All @@ -64,7 +67,7 @@ function svgIcons2svgFontFn(files, options, glyphs = []) {

return new Promise((resolve, reject) => {
fontStream
.on('error', (error) => reject(new Error(error)))
.on('error', (error) => reject(error))
.on('data', (data) => {
result.svg += data;
})
Expand Down

0 comments on commit 41c1d34

Please sign in to comment.