Skip to content

Commit c8cada0

Browse files
Merge pull request mui#1959 from shaurya947/icons-index-gen
[SVG] add Icons index.js
2 parents 8c5d095 + f39790f commit c8cada0

File tree

3 files changed

+866
-0
lines changed

3 files changed

+866
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"react-hot-loader": "^1.2.8",
7474
"react-router": "^1.0.0-rc1",
7575
"react-tap-event-plugin": "^0.2.0",
76+
"recursive-readdir-sync": "^1.0.6",
7677
"rimraf": "^2.4.3",
7778
"sinon": "^1.15.4",
7879
"sinon-chai": "^2.8.0",

src/svg-icons/index-generator.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const fs = require('fs');
2+
const rrs = require('recursive-readdir-sync');
3+
4+
const outArray = [];
5+
outArray.push('module.exports = {\n');
6+
7+
rrs('./').forEach(function(file) {
8+
if(file !== 'index-generator.js' && file !== 'index.js')
9+
{
10+
var fileLines = fs.readFileSync(file, 'utf8').split('\n');
11+
var index = 0, found = false;
12+
13+
while(found === false && index < fileLines.length)
14+
{
15+
if(fileLines[index].indexOf('module.exports') > -1)
16+
{
17+
var moduleName = fileLines[index].split('=')[1].replace(';','').trim();
18+
19+
outArray.push('\t');
20+
outArray.push(moduleName);
21+
outArray.push(': require(\'./');
22+
outArray.push(file.substring(0, file.length - 4));
23+
outArray.push('\'),\n');
24+
25+
found = true;
26+
}
27+
28+
else
29+
{
30+
index++;
31+
}
32+
}
33+
}
34+
});
35+
36+
outArray.push('\n};\n')
37+
38+
fs.writeFileSync('index.js', outArray.join(''));

0 commit comments

Comments
 (0)