-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Icons index gen #1959
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 = []; | ||
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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like eslint is not checking this file, weird. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad, we don't enforce indent in the |
||
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};') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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('')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EOF? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think it's required https://docs.nodejitsu.com/articles/file-system/how-to-write-files-in-nodejs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, we miss the end of line on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
foroutArray
? But we're modifying that throughout.There was a problem hiding this comment.
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 aconst
. If we were using immutable push operation, I would agree, we would need alet
.