Skip to content

Commit

Permalink
Fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyrocks committed Apr 7, 2021
1 parent f0ff204 commit de0e7da
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
package-lock.json
.nyc_output/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Source [SVG](http://en.wikipedia.org/wiki/Scalable_Vector_Graphics) files are in

### renders

Sprite renders of all of the SVGs are in the `renders` directory. High-resolution (aka Retina) versions of each icon are present as well, named using the common `@2x` and `@4x` conventions.
Sprite renders of all of the SVGs are in the `renders` directory. High-resolution (aka Retina) versions of each icon are present as well, named using the common `@1x`, `@2x`, and `@4x` conventions.

### index.js

Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const path = require('path');
const ratios = [1, 2, 4];
const inputPath = '/src/shielded/';
const outputPath = '/renders/shielded/';
const spriteName = 'symbol-library';

ratios.forEach(function(pxRatio) {
console.log(path.join(__dirname, inputPath, '*.svg'));
Expand All @@ -17,8 +18,8 @@ ratios.forEach(function(pxRatio) {
id: path.basename(f).replace('.svg', '')
};
});
let pngPath = path.resolve(path.join(__dirname, outputPath, '/sprite@' + pxRatio + '.png'));
let jsonPath = path.resolve(path.join(__dirname, outputPath, '/sprite@' + pxRatio + '.json'));
let pngPath = path.resolve(path.join(__dirname, outputPath, '/' + spriteName + '@' + pxRatio + 'x.png'));
let jsonPath = path.resolve(path.join(__dirname, outputPath, '/' + spriteName + '@' + pxRatio + 'x.json'));

// Pass `true` in the layout parameter to generate a data layout
// suitable for exporting to a JSON sprite manifest file.
Expand Down
32 changes: 17 additions & 15 deletions test/npmap-symbol-library.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
/* globals require __dirname */

const fs = require('fs');
const test = require('tap').test;

const renderedPath = __dirname + '/../renders/sheilded/';
const renderedPath = __dirname + '/../renders/shielded/';
const inputPath = __dirname + '/../src/shielded/';
const sizes = [14, 22, 30];

test('NPMap Symbol Library', function (t) {
let jsonStandalone;
let jsonShielded;

t.doesNotThrow(function () {
jsonStandalone = JSON.parse(fs.readFileSync(renderedPath + '/[email protected]'));
}, 'Standalone JSON is invalid');
jsonStandalone.forEach(function (f) {
t.equal(typeof f.name, 'string', 'name property');
t.equal(typeof f.icon, 'string', 'icon property');
t.equal(typeof f.release, 'string', 'release property');
t.equal(typeof f.tags, 'object', 'tags property');
sizes.forEach(function (size) {
t.doesNotThrow(function () {
fs.statSync(inputPath + f.icon + '-' + size + '.svg');
}, 'source file present');
});
jsonShielded = JSON.parse(fs.readFileSync(renderedPath + '[email protected]'));
}, 'Shielded JSON file is invalid');
Object.keys(jsonShielded).forEach(function (key) {
let f = jsonShielded[key];
t.equal(typeof key, 'string', 'name property');
t.equal(typeof f.width, 'number', 'width property');
t.equal(typeof f.height, 'number', 'height property');
t.equal(typeof f.x, 'number', 'x property');
t.equal(typeof f.y, 'number', 'y property');
t.equal(typeof f.pixelRatio, 'number', 'pixelRatioproperty');
t.doesNotThrow(function () {
fs.statSync(inputPath + key + '.svg');
}, 'source file present');
});
t.end();
});

0 comments on commit de0e7da

Please sign in to comment.