Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons index gen #1959

Merged
merged 3 commits into from
Oct 21, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');

var outArray = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const for outArray? But we're modifying that throughout.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outArray is a mutated object, push is not changing the reference, hence we should use a const. If we were using immutable push operation, I would agree, we would need a let.

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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the eslint task will fail since you are using tab and not space for indent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like eslint is not checking this file, weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm install works for me (ESLint doesn't fail). That's what you meant right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, we don't enforce indent in the .eslintrc. Ok, let's keep it like it. I think that once we take care of the huge number of PR, we can use the autofix of eslint to clean the mess in MUI.

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};')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use '\n};\n'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, will change that in a commit.


fs.writeFileSync('index.js', outArray.join(''));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we miss the end of line on /index-generator.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see.

Loading