forked from mui/material-ui
-
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.
Merge pull request mui#1959 from shaurya947/icons-index-gen
[SVG] add Icons index.js
- Loading branch information
Showing
3 changed files
with
866 additions
and
0 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,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('')); |
Oops, something went wrong.