Closed eHammarstrom closed 7 years ago
Currently file-extensions.js merely contains a listing of files but could also contain the meta-info that is needed for getCommentChars().
file-extensions.js
getCommentChars()
Current state utils.js:
utils.js
function getCommentChars (extension) { switch (extension) { case 'c': return { ... } case 'cc: ... } }
suggestion, move meta-info such as multi-line and single-line data into file-extensions.js
Example file-extensions.js:
module.exports = [ { lang: 'java', single: '//', multi: { start: '/*', end: '*/' } }, { lang: 'rb', single: '#', multi: { start: '=begin', end: '=end' } } ]
Example usage:
// line 7 in bin/node-sloc.js const allowedExtensions = require('./file-extensions.js').map(x => x.lang) console.log(allowedExtensions) // [ 'java', 'rb' ] // line ~158 in utils.js function getCommentChars (extension) { let ext = allowedExtensions.find(x => x.lang === extension) return { line: ext.single, multi: ext.multi } } console.log(getCommentChars('java')) // { line: '//', multi: { start: '/*', end: '*/' } }
Sounds sane enough?
Currently
file-extensions.js
merely contains a listing of files but could also contain the meta-info that is needed forgetCommentChars()
.Current state
utils.js
:suggestion, move meta-info such as multi-line and single-line data into
file-extensions.js
Example
file-extensions.js
:Example usage:
Sounds sane enough?