diff --git a/bin/__tests__/__snapshots__/build-sprite-string.test.js.snap b/bin/__tests__/__snapshots__/build-sprite-string.test.js.snap index 8371f2e..e91b092 100644 --- a/bin/__tests__/__snapshots__/build-sprite-string.test.js.snap +++ b/bin/__tests__/__snapshots__/build-sprite-string.test.js.snap @@ -1,14 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`builds sprite correctly 1`] = ` -" - - - - - - - - -" -`; +exports[`builds sprite correctly 1`] = `""`; diff --git a/bin/build-sprite-string.js b/bin/build-sprite-string.js index fcea913..1dcaf6e 100644 --- a/bin/build-sprite-string.js +++ b/bin/build-sprite-string.js @@ -1,30 +1,28 @@ import defaultAttrs from '../src/default-attrs.json'; -const svgStartTag = `\n\n`; -const svgEndTag = '\n'; - /** - * Renders the inner sprites as SVG Symbols - * @param {object} icons the icons object - * @returns {string} the rendered string with SVG symbols + * Build an SVG sprite string containing SVG symbols. + * @param {Object} icons + * @returns {string} */ function buildSpriteString(icons) { const symbols = Object.keys(icons) .map(icon => toSvgSymbol(icon, icons[icon])) .join(''); - return svgStartTag + symbols + svgEndTag; + return `${symbols}`; } /** - * Renders a SVG symbol tag - * @param {string} name The name of the icon - * @param {string} contents The contents of the icon - * @returns {string} the rendered SVG symbol + * Create an SVG symbol string. + * @param {string} name - Icon name + * @param {string} contents - SVG contents + * @returns {string} */ function toSvgSymbol(name, contents) { - return ` -${contents}\n\n`; + return `${ + contents + }`; } export default buildSpriteString; diff --git a/bin/build-sprite.js b/bin/build-sprite.js index b1a3b8e..1207b77 100644 --- a/bin/build-sprite.js +++ b/bin/build-sprite.js @@ -3,12 +3,8 @@ import path from 'path'; import icons from '../dist/icons.json'; import buildSpriteString from './build-sprite-string'; -const sprite = buildSpriteString(icons); - const OUT_FILE = path.resolve(__dirname, '../dist/feather-sprite.svg'); console.log(`Building ${OUT_FILE}`); // eslint-disable-line no-console -fs.writeFile(OUT_FILE, sprite, err => { - if (err) throw err; -}); +fs.writeFileSync(OUT_FILE, buildSpriteString(icons));