Skip to content

Commit

Permalink
Merge pull request mui#1959 from shaurya947/icons-index-gen
Browse files Browse the repository at this point in the history
[SVG] add Icons index.js
  • Loading branch information
oliviertassinari committed Oct 21, 2015
2 parents 8c5d095 + f39790f commit c8cada0
Show file tree
Hide file tree
Showing 3 changed files with 866 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"react-hot-loader": "^1.2.8",
"react-router": "^1.0.0-rc1",
"react-tap-event-plugin": "^0.2.0",
"recursive-readdir-sync": "^1.0.6",
"rimraf": "^2.4.3",
"sinon": "^1.15.4",
"sinon-chai": "^2.8.0",
Expand Down
38 changes: 38 additions & 0 deletions src/svg-icons/index-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const fs = require('fs');
const rrs = require('recursive-readdir-sync');

const outArray = [];
outArray.push('module.exports = {\n');

rrs('./').forEach(function(file) {
if(file !== 'index-generator.js' && file !== 'index.js')
{
var fileLines = fs.readFileSync(file, 'utf8').split('\n');
var index = 0, found = false;

while(found === false && index < fileLines.length)
{
if(fileLines[index].indexOf('module.exports') > -1)
{
var moduleName = fileLines[index].split('=')[1].replace(';','').trim();

outArray.push('\t');
outArray.push(moduleName);
outArray.push(': require(\'./');
outArray.push(file.substring(0, file.length - 4));
outArray.push('\'),\n');

found = true;
}

else
{
index++;
}
}
}
});

outArray.push('\n};\n')

fs.writeFileSync('index.js', outArray.join(''));
Loading

0 comments on commit c8cada0

Please sign in to comment.