File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var through = require ( 'through' ) ,
2+ extend = require ( 'extend' ) ,
23 SVGO = require ( 'svgo' ) ,
34 react = require ( 'react-tools' ) ;
45
6+ var svgo = new SVGO ( ) ;
7+
8+ var settings = {
9+ react : {
10+ es5 : true ,
11+ sourceMap : false ,
12+ stripTypes : false ,
13+ harmony : false
14+ } ,
15+ svgo : { }
16+ } ;
17+
518var isSVG = function ( filename ) {
619
720 return ( / \. s v g $ / i) . test ( filename ) ;
821} ;
922
10- var svgo = new SVGO ( ) ;
11-
12- module . exports = function ( filename ) {
23+ var transform = function ( filename ) {
1324
1425 var write = function ( buffer ) {
1526
@@ -24,13 +35,7 @@ module.exports = function (filename) {
2435 var out = function ( svg ) {
2536
2637 var source = "var React = require('react');module.exports = React.createClass({render: function () { return (" + svg . data + "); }});" ,
27- output = react . transform ( source , {
28- es5 : true ,
29- sourceMap : false ,
30- sourceFilename : filename ,
31- stripTypes : false ,
32- harmony : false
33- } ) ;
38+ output = react . transform ( source , settings . react ) ;
3439
3540 stream . queue ( output ) ;
3641 stream . queue ( null ) ;
@@ -41,3 +46,18 @@ module.exports = function (filename) {
4146
4247 return stream ;
4348} ;
49+
50+ module . exports = function ( a ) {
51+
52+ if ( typeof a === 'string' || a instanceof String ) {
53+
54+ return transform ( a ) ;
55+ }
56+
57+ extend ( settings . react , a . react ) ;
58+ extend ( settings . svgo , a . svgo ) ;
59+
60+ svgo = new SVGO ( settings . svgo ) ;
61+
62+ return transform ;
63+ } ;
Original file line number Diff line number Diff line change 44 "homepage" : " https://github.com/coma/svg-reactify" ,
55 "repository" : " https://github.com/coma/svg-reactify" ,
66 "main" : " ./index.js" ,
7- "version" : " 0.2 .0" ,
7+ "version" : " 0.3 .0" ,
88 "license" : " MIT" ,
99 "private" : false ,
1010 "authors" : [
1919 "dependencies" : {
2020 "through" : " ^2.3" ,
2121 "react-tools" : " ^0.13" ,
22- "svgo" : " ^0.5"
22+ "svgo" : " ^0.5" ,
23+ "extend" : " ^2"
2324 },
2425 "devDependencies" : {},
2526 "scripts" : {},
You can’t perform that action at this time.
0 commit comments