@@ -28,9 +28,12 @@ function getCommitSha(repoId, repoPath) {
2828 } ) ;
2929}
3030
31- function download ( urlString ) {
31+ function download ( source ) {
32+ if ( source . startsWith ( '.' ) ) {
33+ return readFile ( source ) ;
34+ }
3235 return new Promise ( ( c , e ) => {
33- var _url = url . parse ( urlString ) ;
36+ var _url = url . parse ( source ) ;
3437 var options = { host : _url . host , port : _url . port , path : _url . path , headers : { 'User-Agent' : 'NodeJS' } } ;
3538 var content = '' ;
3639 https . get ( options , function ( response ) {
@@ -45,9 +48,25 @@ function download(urlString) {
4548 } ) ;
4649}
4750
48- function downloadBinary ( urlString , dest ) {
51+ function readFile ( fileName ) {
4952 return new Promise ( ( c , e ) => {
50- https . get ( urlString , function ( response ) {
53+ fs . readFile ( fileName , function ( err , data ) {
54+ if ( err ) {
55+ e ( err ) ;
56+ } else {
57+ c ( data . toString ( ) ) ;
58+ }
59+ } ) ;
60+ } ) ;
61+ }
62+
63+ function downloadBinary ( source , dest ) {
64+ if ( source . startsWith ( '.' ) ) {
65+ return copyFile ( source , dest ) ;
66+ }
67+
68+ return new Promise ( ( c , e ) => {
69+ https . get ( source , function ( response ) {
5170 switch ( response . statusCode ) {
5271 case 200 :
5372 var file = fs . createWriteStream ( dest ) ;
@@ -75,6 +94,29 @@ function downloadBinary(urlString, dest) {
7594 } ) ;
7695}
7796
97+ function copyFile ( fileName , dest ) {
98+ return new Promise ( ( c , e ) => {
99+ var cbCalled = false ;
100+ function handleError ( err ) {
101+ if ( ! cbCalled ) {
102+ e ( err ) ;
103+ cbCalled = true ;
104+ }
105+ }
106+ var rd = fs . createReadStream ( fileName ) ;
107+ rd . on ( "error" , handleError ) ;
108+ var wr = fs . createWriteStream ( dest ) ;
109+ wr . on ( "error" , handleError ) ;
110+ wr . on ( "close" , function ( ) {
111+ if ( ! cbCalled ) {
112+ c ( ) ;
113+ cbCalled = true ;
114+ }
115+ } ) ;
116+ rd . pipe ( wr ) ;
117+ } ) ;
118+ }
119+
78120function invertColor ( color ) {
79121 var res = '#' ;
80122 for ( var i = 1 ; i < 7 ; i += 2 ) {
@@ -111,13 +153,23 @@ function getLanguageMappings() {
111153 return langToExt ;
112154}
113155
156+ //var font = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/_fonts/seti/seti.woff';
157+ var font = '../../../seti-ui/styles/_fonts/seti/seti.woff' ;
158+
114159exports . copyFont = function ( ) {
115- var fontURI = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/_fonts/seti/seti.woff' ;
116- return downloadBinary ( fontURI , './icons/seti.woff' ) ;
160+ return downloadBinary ( font , './icons/seti.woff' ) ;
117161} ;
118162
163+ //var fontMappings = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/_fonts/seti.less';
164+ //var mappings = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/icons/mapping.less';
165+ //var colors = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/ui-variables.less';
166+
167+ var fontMappings = '../../../seti-ui/styles/_fonts/seti.less' ;
168+ var mappings = '../../../seti-ui/styles/icons/mapping.less' ;
169+ var colors = '../../../seti-ui/styles/ui-variables.less' ;
170+
119171exports . update = function ( ) {
120- var fontMappings = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/_fonts/seti.less' ;
172+
121173 console . log ( 'Reading from ' + fontMappings ) ;
122174 var def2Content = { } ;
123175 var ext2Def = { } ;
@@ -192,7 +244,6 @@ exports.update = function () {
192244 def2Content [ '_' + match [ 1 ] ] = match [ 2 ] ;
193245 }
194246
195- var mappings = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/icons/mapping.less' ;
196247 return download ( mappings ) . then ( function ( content ) {
197248 var regex2 = / \. i c o n - (?: s e t | p a r t i a l ) \( ' ( [ \w -\. ] + ) ' , \s * ' ( [ \w - ] + ) ' , \s * ( @ [ \w - ] + ) \) / g;
198249 while ( ( match = regex2 . exec ( content ) ) !== null ) {
@@ -226,7 +277,7 @@ exports.update = function () {
226277 }
227278 }
228279
229- var colors = 'https://raw.githubusercontent.com/jesseweed/seti-ui/master/styles/ui-variables.less' ;
280+
230281 return download ( colors ) . then ( function ( content ) {
231282 var regex3 = / ( @ [ \w - ] + ) : \s * ( # [ 0 - 9 a - z ] + ) / g;
232283 while ( ( match = regex3 . exec ( content ) ) !== null ) {
0 commit comments