diff --git a/CHANGELOG.md b/CHANGELOG.md index d23544da..3ac215fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 6.0.4 - 2016-11-08 + +- Fixed: regression bug with passed arguments to template. + # 6.0.3 - 2016-11-08 - Fixed: validate `xml` of glyphs. diff --git a/package.json b/package.json index 2c544a8d..f7c188ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webfont", - "version": "6.0.3", + "version": "6.0.4", "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 ", diff --git a/src/__tests__/standalone-test.js b/src/__tests__/standalone-test.js index d501d316..bb0c4c14 100644 --- a/src/__tests__/standalone-test.js +++ b/src/__tests__/standalone-test.js @@ -69,10 +69,28 @@ test('should generated only `woff2` font', (t) => { }); }); -// In future improve css tests on valid based on postcss +test('should generated all fonts with css', (t) => { + t.plan(8); + + return standalone({ + css: true, + files: `${fixturesPath}/svg-icons/**/*` + }).then((result) => { + t.true(isSvg(result.svg)); + t.true(isTtf(result.ttf)); + t.true(isEot(result.eot)); + t.true(isWoff(result.woff)); + t.true(isWoff2(result.woff2)); + t.regex(result.css, /\.webfont-avatar/); + t.regex(result.css, /\.webfont-envelope/); + t.regex(result.css, /\.webfont-phone-call/); + + return result; + }); +}); test('should generated only `woff and `woff2` fonts with css', (t) => { - t.plan(6); + t.plan(8); return standalone({ css: true, @@ -84,33 +102,36 @@ test('should generated only `woff and `woff2` fonts with css', (t) => { t.true(typeof result.eot === 'undefined'); t.true(isWoff(result.woff)); t.true(isWoff2(result.woff2)); - t.true(result.css.length > 0); // eslint-disable-line ava/max-asserts + t.regex(result.css, /\.webfont-avatar/); + t.regex(result.css, /\.webfont-envelope/); + t.regex(result.css, /\.webfont-phone-call/); return result; }); }); test('should generated all fonts and css', (t) => { - t.plan(6); + t.plan(8); return standalone({ css: true, files: `${fixturesPath}/svg-icons/**/*` }).then((result) => { - /* eslint-disable ava/max-asserts */ t.true(isSvg(result.svg)); t.true(isTtf(result.ttf)); t.true(isEot(result.eot)); t.true(isWoff(result.woff)); t.true(isWoff2(result.woff2)); - t.true(result.css.length > 0); // eslint-disable-line ava/max-asserts + t.regex(result.css, /\.webfont-avatar/); + t.regex(result.css, /\.webfont-envelope/); + t.regex(result.css, /\.webfont-phone-call/); return result; }); }); test('should generated all fonts with `css` by passed template', (t) => { - t.plan(6); + t.plan(9); return standalone({ css: true, @@ -122,7 +143,10 @@ test('should generated all fonts with `css` by passed template', (t) => { t.true(isEot(result.eot)); t.true(isWoff(result.woff)); t.true(isWoff2(result.woff2)); - t.is(result.css.slice(0, 21), '/* custom template */'); + t.regex(result.css, /\/\*\scustom template\s\*\//); + t.regex(result.css, /\.webfont-avatar/); + t.regex(result.css, /\.webfont-envelope/); + t.regex(result.css, /\.webfont-phone-call/); return result; }); diff --git a/src/standalone.js b/src/standalone.js index 310a229b..65bb9034 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -214,7 +214,7 @@ export default function ({ return Promise.reject(new Error('You must pass webfont a `files` glob')); } - let glyphsData = null; + let glyphsData = []; return buildConfig({ configFile @@ -259,16 +259,12 @@ export default function ({ return Promise.resolve(filteredFiles); }) - .then((foundFiles) => { - glyphsData = getGlyphsData(foundFiles, options); - - if (!glyphsData) { - throw new Error('Can\'t get glyphs data'); - } + .then((foundFiles) => getGlyphsData(foundFiles, options)) + .then((returnedGlyphsData) => { + glyphsData = returnedGlyphsData; - return glyphsData; + return svgIcons2svgFontFn(returnedGlyphsData, options); }) - .then((returnedGlyphsData) => svgIcons2svgFontFn(returnedGlyphsData, options)) .then((result) => svg2ttfFn(result, options.formatsOptions.ttf)) // maybe add ttfautohint .then((result) => { @@ -311,7 +307,7 @@ export default function ({ const nunjucksOptions = merge( {}, { - glyphsData + glyphs: glyphsData.map((glyphData) => glyphData.metadata) }, options, {