@@ -10,6 +10,30 @@ let fs = require('fs');
1010let https = require ( 'https' ) ;
1111let url = require ( 'url' ) ;
1212
13+ // list of languagesIs not shipped with VSCode. The information is used to associate an icon with a langauge association
14+ let nonBuiltInLanguages = { // { fileNames, extensions }
15+ "r" : { extensions : [ 'r' , 'rhistory' , 'rprofile' , 'rt' ] } ,
16+ "argdown" : { extensions : [ 'ad' , 'adown' , 'argdown' , 'argdn' ] } ,
17+ "elm" : { extensions : [ 'elm' ] } ,
18+ "ocaml" : { extensions : [ 'ml' , 'mli' ] } ,
19+ "nunjucks" : { extensions : [ 'nunjucks' , 'nunjs' , 'nunj' , 'nj' , 'njk' , 'tmpl' , 'tpl' ] } ,
20+ "mustache" : { extensions : [ 'mustache' , 'mst' , 'mu' , 'stache' ] } ,
21+ "erb" : { extensions : [ 'erb' , 'rhtml' , 'html.erb' ] } ,
22+ "terraform" : { extensions : [ 'tf' , 'tfvars' , 'hcl' ] } ,
23+ "vue" : { extensions : [ 'vue' ] } ,
24+ "sass" : { extensions : [ 'sass' ] } ,
25+ "puppet" : { extensions : [ 'puppet' ] } ,
26+ "kotlin" : { extensions : [ 'kt' ] } ,
27+ "jinja" : { extensions : [ 'jinja' ] } ,
28+ "haxe" : { extensions : [ 'hx' ] } ,
29+ "haskell" : { extensions : [ 'hs' ] } ,
30+ "gradle" : { extensions : [ 'gradle' ] } ,
31+ "elixir" : { extensions : [ 'ex' ] } ,
32+ "haml" : { extensions : [ 'haml' ] } ,
33+ "stylus" : { extensions : [ 'styl' ] } ,
34+ "vala" : { extensions : [ 'vala' ] }
35+ }
36+
1337function getCommitSha ( repoId , repoPath ) {
1438 let commitInfo = 'https://api.github.com/repos/' + repoId + '/commits?path=' + repoPath ;
1539 return download ( commitInfo ) . then ( function ( content ) {
@@ -34,7 +58,7 @@ function download(source) {
3458 }
3559 return new Promise ( ( c , e ) => {
3660 let _url = url . parse ( source ) ;
37- let options = { host : _url . host , port : _url . port , path : _url . path , headers : { 'User-Agent' : 'NodeJS' } } ;
61+ let options = { host : _url . host , port : _url . port , path : _url . path , headers : { 'User-Agent' : 'NodeJS' } } ;
3862 let content = '' ;
3963 https . get ( options , function ( response ) {
4064 response . on ( 'data' , function ( data ) {
@@ -50,7 +74,7 @@ function download(source) {
5074
5175function readFile ( fileName ) {
5276 return new Promise ( ( c , e ) => {
53- fs . readFile ( fileName , function ( err , data ) {
77+ fs . readFile ( fileName , function ( err , data ) {
5478 if ( err ) {
5579 e ( err ) ;
5680 } else {
@@ -67,12 +91,12 @@ function downloadBinary(source, dest) {
6791
6892 return new Promise ( ( c , e ) => {
6993 https . get ( source , function ( response ) {
70- switch ( response . statusCode ) {
94+ switch ( response . statusCode ) {
7195 case 200 :
7296 let file = fs . createWriteStream ( dest ) ;
73- response . on ( 'data' , function ( chunk ) {
97+ response . on ( 'data' , function ( chunk ) {
7498 file . write ( chunk ) ;
75- } ) . on ( 'end' , function ( ) {
99+ } ) . on ( 'end' , function ( ) {
76100 file . end ( ) ;
77101 c ( null ) ;
78102 } ) . on ( 'error' , function ( err ) {
@@ -107,7 +131,7 @@ function copyFile(fileName, dest) {
107131 rd . on ( "error" , handleError ) ;
108132 let wr = fs . createWriteStream ( dest ) ;
109133 wr . on ( "error" , handleError ) ;
110- wr . on ( "close" , function ( ) {
134+ wr . on ( "close" , function ( ) {
111135 if ( ! cbCalled ) {
112136 c ( ) ;
113137 cbCalled = true ;
@@ -119,7 +143,7 @@ function copyFile(fileName, dest) {
119143
120144function darkenColor ( color ) {
121145 let res = '#' ;
122- for ( let i = 1 ; i < 7 ; i += 2 ) {
146+ for ( let i = 1 ; i < 7 ; i += 2 ) {
123147 let newVal = Math . round ( parseInt ( '0x' + color . substr ( i , 2 ) , 16 ) * 0.9 ) ;
124148 let hex = newVal . toString ( 16 ) ;
125149 if ( hex . length == 1 ) {
@@ -133,7 +157,7 @@ function darkenColor(color) {
133157function getLanguageMappings ( ) {
134158 let langMappings = { } ;
135159 let allExtensions = fs . readdirSync ( '..' ) ;
136- for ( let i = 0 ; i < allExtensions . length ; i ++ ) {
160+ for ( let i = 0 ; i < allExtensions . length ; i ++ ) {
137161 let dirPath = path . join ( '..' , allExtensions [ i ] , 'package.json' ) ;
138162 if ( fs . existsSync ( dirPath ) ) {
139163 let content = fs . readFileSync ( dirPath ) . toString ( ) ;
@@ -158,13 +182,16 @@ function getLanguageMappings() {
158182 }
159183 }
160184 }
185+ for ( let languageId in nonBuiltInLanguages ) {
186+ langMappings [ languageId ] = nonBuiltInLanguages [ languageId ] ;
187+ }
161188 return langMappings ;
162189}
163190
164191//let font = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/_fonts/seti/seti.woff';
165192let font = '../../../seti-ui/styles/_fonts/seti/seti.woff' ;
166193
167- exports . copyFont = function ( ) {
194+ exports . copyFont = function ( ) {
168195 return downloadBinary ( font , './icons/seti.woff' ) ;
169196} ;
170197
@@ -234,7 +261,7 @@ exports.update = function () {
234261 size : "150%"
235262 } ] ,
236263 iconDefinitions : iconDefinitions ,
237- // folder: "_folder",
264+ // folder: "_folder",
238265 file : "_default" ,
239266 fileExtensions : ext2Def ,
240267 fileNames : fileName2Def ,
@@ -304,16 +331,18 @@ exports.update = function () {
304331 }
305332 if ( preferredDef ) {
306333 lang2Def [ lang ] = preferredDef ;
307- for ( let i2 = 0 ; i2 < exts . length ; i2 ++ ) {
308- // remove the extension association, unless it is different from the preferred
309- if ( ext2Def [ exts [ i2 ] ] === preferredDef ) {
310- delete ext2Def [ exts [ i2 ] ] ;
334+ if ( ! nonBuiltInLanguages [ lang ] ) {
335+ for ( let i2 = 0 ; i2 < exts . length ; i2 ++ ) {
336+ // remove the extension association, unless it is different from the preferred
337+ if ( ext2Def [ exts [ i2 ] ] === preferredDef ) {
338+ delete ext2Def [ exts [ i2 ] ] ;
339+ }
311340 }
312- }
313- for ( let i2 = 0 ; i2 < fileNames . length ; i2 ++ ) {
314- // remove the fileName association, unless it is different from the preferred
315- if ( fileName2Def [ fileNames [ i2 ] ] === preferredDef ) {
316- delete fileName2Def [ fileNames [ i2 ] ] ;
341+ for ( let i2 = 0 ; i2 < fileNames . length ; i2 ++ ) {
342+ // remove the fileName association, unless it is different from the preferred
343+ if ( fileName2Def [ fileNames [ i2 ] ] === preferredDef ) {
344+ delete fileName2Def [ fileNames [ i2 ] ] ;
345+ }
317346 }
318347 }
319348 }
@@ -323,7 +352,7 @@ exports.update = function () {
323352 return download ( colorsFile ) . then ( function ( content ) {
324353 let regex3 = / ( @ [ \w - ] + ) : \s * ( # [ 0 - 9 a - z ] + ) / g;
325354 while ( ( match = regex3 . exec ( content ) ) !== null ) {
326- colorId2Value [ match [ 1 ] ] = match [ 2 ] ;
355+ colorId2Value [ match [ 1 ] ] = match [ 2 ] ;
327356 }
328357 return getCommitSha ( 'jesseweed/seti-ui' , 'styles/_fonts/seti.less' ) . then ( function ( info ) {
329358 try {
0 commit comments