-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update SVG optimization workflow (#1215)
* Update optimize svg script * Update tests * Update error message * Remove extra newline * Update test scripts * Optimize svgs
- Loading branch information
Showing
295 changed files
with
328 additions
and
4,283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`optimizes SVG correctly 1`] = `"<svg xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"currentColor\\" stroke-width=\\"2\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\"><line x1=\\"23\\" y1=\\"1\\" x2=\\"1\\" y2=\\"23\\"/><line x1=\\"1\\" y1=\\"1\\" x2=\\"23\\" y2=\\"23\\"/></svg>"`; | ||
exports[`rejects when passed unparsable SVG string 1`] = ` | ||
[Error: Error in parsing SVG: Unclosed root tag | ||
Line: 0 | ||
Column: 10 | ||
Char: ] | ||
`; |
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
bin/__tests__/process-svg.test.js → bin/__tests__/optimize-svg.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/* eslint-env jest */ | ||
import processSvg from '../process-svg'; | ||
import optimizeSvg from '../optimize-svg'; | ||
|
||
test('processes SVG correctly', () => { | ||
test('optimizes SVG correctly', () => { | ||
const SVG = | ||
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><title>Title</title><line x1="23" y1="1" x2="1" y2="23" fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/><line x1="1" y1="1" x2="23" y2="23" fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/></svg>'; | ||
|
||
expect(processSvg(SVG)).resolves.toMatchSnapshot(); | ||
expect(optimizeSvg(SVG)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
test('rejects when passed unparsable SVG string', () => { | ||
const UNPARSABLE_SVG = '<svg></svg'; | ||
|
||
expect(processSvg(UNPARSABLE_SVG)).rejects.toMatchSnapshot(); | ||
expect(optimizeSvg(UNPARSABLE_SVG)).rejects.toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import processSvg from './process-svg'; | ||
import optimizeSvg from './optimize-svg'; | ||
|
||
const IN_DIR = path.resolve(__dirname, '../icons'); | ||
|
||
console.log(`Processing SVGs in ${IN_DIR}...`); | ||
console.log(`Optimizing SVGs in ${IN_DIR}...`); | ||
|
||
fs.readdirSync(IN_DIR) | ||
.filter(file => path.extname(file) === '.svg') | ||
.forEach(svgFile => { | ||
const svg = fs.readFileSync(path.join(IN_DIR, svgFile)); | ||
processSvg(svg).then(svg => | ||
optimizeSvg(svg).then(svg => | ||
fs.writeFileSync(path.join(IN_DIR, svgFile), svg), | ||
); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.