-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Search through files via node-glob - Use _.defaults for default options - Custom filters are now more flexible, output relative to options.outputDir / --output-dir - mui-icons no longer needs --file-suffix, _24px.svg -> .jsx happens in filter. - pascalCase now capitalizes first letter of recursive directories and dashes.
- Loading branch information
Showing
6 changed files
with
131 additions
and
102 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
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,12 +1,29 @@ | ||
function defaultFilter(fileName, fileSuffix) { | ||
if (fileSuffix) { | ||
fileName.replace(fileSuffix, ".svg"); | ||
/* | ||
* Return path to write file to inside outputDir. | ||
* | ||
* @param {object} pathObj | ||
* path objects from path.parse | ||
* | ||
* @param {string} innerPath | ||
* Path (relative to options.svgDir) to svg file | ||
* e.g. if svgFile was /home/user/icons/path/to/svg/file.svg | ||
* options.svgDir is /home/user/icons/ | ||
* innerPath is path/to/svg | ||
* | ||
* @param {object} options | ||
* @return {string} output file dest relative to outputDir | ||
*/ | ||
function defaultDestRewriter(pathObj, innerPath, options) { | ||
var path = require('path'); | ||
var fileName = pathObj.base; | ||
if (options.fileSuffix) { | ||
fileName.replace(options.fileSuffix, ".svg"); | ||
} else { | ||
fileName = fileName.replace('.svg', '.jsx'); | ||
} | ||
fileName = fileName.replace(/_/g, '-'); | ||
return fileName; | ||
return path.join(innerPath, fileName); | ||
} | ||
|
||
|
||
module.exports = defaultFilter; | ||
module.exports = defaultDestRewriter; |
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,14 +1,18 @@ | ||
function myFilter(fileName, fileSuffix) { | ||
if (fileSuffix && fileName.indexOf(fileSuffix, fileName.length - fileSuffix.length) !== -1) { | ||
fileName = fileName.replace(fileSuffix, '.jsx'); | ||
fileName = fileName.slice(3); | ||
fileName = fileName.replace(/_/g, '-'); | ||
|
||
if (fileName.indexOf('3d') === 0) { | ||
fileName = 'three-d' + fileName.slice(2); | ||
} | ||
return fileName; | ||
function myDestRewriter(pathObj, innerPath, options) { | ||
var path = require('path'); | ||
var fileName = pathObj.base; | ||
|
||
var rewrittenInnerPath = innerPath.replace('/svg/production', ''); | ||
|
||
fileName = fileName.replace('_24px.svg', '.jsx'); | ||
fileName = fileName.slice(3); | ||
fileName = fileName.replace(/_/g, '-'); | ||
|
||
if (fileName.indexOf('3d') === 0) { | ||
fileName = 'three-d' + fileName.slice(2); | ||
} | ||
|
||
return path.join(rewrittenInnerPath, fileName); | ||
} | ||
|
||
module.exports = myFilter; | ||
module.exports = myDestRewriter; |
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