diff options
author | Curtis Hard <curtishard@me.com> | 2015-06-04 08:15:39 +0100 |
---|---|---|
committer | Curtis Hard <curtishard@me.com> | 2015-06-04 08:15:39 +0100 |
commit | 9e875ad420ec0e403fd0a7d626ad8c39a24a6784 (patch) | |
tree | a787bb016359de4f65f2e210abbf7fb65fc73f4f | |
parent | 9e580ba3a0bd374935010b4c53495e79df0b04b0 (diff) |
Formatting fixes for Google guidlines
-rw-r--r-- | iconfont/iconjar-map.js | 72 |
1 files changed, 30 insertions, 42 deletions
diff --git a/iconfont/iconjar-map.js b/iconfont/iconjar-map.js index d9a4ea93209d..03b4d44f3f47 100644 --- a/iconfont/iconjar-map.js +++ b/iconfont/iconjar-map.js @@ -2,51 +2,39 @@ var fileSystem = require( 'fs' ); var readLine = require( 'readline' ); var path = require( 'path' ); - -// find the filename we wish to use -var name = null; -var dirListing = fileSystem.readdirSync( __dirname ); -for( var i = 0; i < dirListing.length; i++ ) { - // look for TTF, we want the name of it so - // we can replace the extension with ijmap - var fileFound = dirListing[i] - if( path.extname(fileFound) === '.ttf' ) - { - name = path.basename(fileFound).replace( path.extname(fileFound), '' ); - break; - } -}; - +// file name we want to generate +var MAP_FILE_NAME = 'MaterialIcons-Regular.ijmap'; + // create a file streaming interface var readLineHandle = readLine.createInterface({ - input: fileSystem.createReadStream( 'codepoints' ), - output: process.stdout, - terminal: false + input: fileSystem.createReadStream('codepoints'), + output: process.stdout, + terminal: false }); - + // read each line by line from the file codepoints file -var json = {icons:{}}; -readLineHandle.on( 'line', function( line ) { - - // match the name, space then any unicode after it - var match = line.match( /(.*)\s([a-f0-9]+)/i ); - - // convert the name into something a little more friendly for IconJar - // tags will also be based on this - var unicode = match[2]; - var name = match[1].toLowerCase().replace( /[^a-z]+/gi, ' ' ).replace( /\b[a-z]/g, function ( char ) { - return char.toUpperCase(); - } ).trim(); - - // assign the unicode to the name for IconJar - json.icons[unicode] = { - name: name - } +var json = {icons: {}}; +readLineHandle.on('line', function (line) { + + // match the name, space then any unicode after it + var match = line.split(' '); + + // convert the name into something a little more friendly for IconJar + // tags will also be based on this + var unicode = match[1]; + var name = match[0].toLowerCase().replace(/[^0-9a-z]+/gi, ' ').replace(/\b[a-z]/g, function (char) { + return char.toUpperCase(); + } ).trim(); + + // assign the unicode to the name for IconJar + json.icons[unicode] = { + name: name + } }); - -readLineHandle.on( 'close', function() { - // once reading has finished - // here we can write the file - fileSystem.writeFileSync( name + '.ijmap', JSON.stringify(json)); -} );
\ No newline at end of file + +readLineHandle.on('close', function () { + // once reading has finished + // here we can write the file + fileSystem.writeFileSync(MAP_FILE_NAME, JSON.stringify(json)); +});
\ No newline at end of file |