55 ************************************************************************************/
66"use strict" ;
77
8- var fs = require ( 'fs' ) ;
9- var path = require ( 'path' ) ;
10- var sass = require ( 'node-sass' ) ;
11- var glob = require ( 'glob' ) ;
8+ var fs = require ( "fs" ) ;
9+ var sass = require ( "node-sass" ) ;
10+ var glob = require ( "glob" ) ;
1211
1312// Kill The original folder, so that way it is a clean folder
14- if ( fs . existsSync ( ' nativescript-theme-core' ) ) {
15- deleteFolderRecursive ( ' nativescript-theme-core' ) ;
13+ if ( fs . existsSync ( " nativescript-theme-core" ) ) {
14+ deleteFolderRecursive ( " nativescript-theme-core" ) ;
1615}
1716fs . mkdirSync ( "nativescript-theme-core" ) ;
1817fs . mkdirSync ( "nativescript-theme-core/css" ) ;
@@ -55,21 +54,25 @@ console.log("Change to the 'nativescript-theme-core' folder and you can now do y
5554 * Copy any fonts files over
5655 */
5756function copyFonts ( ) {
58- var ttfFiles = glob . sync ( ' ./app/fonts/*.ttf' ) ;
59- var otfFiles = glob . sync ( ' ./app/fonts/*.otf' ) ;
57+ var ttfFiles = glob . sync ( " ./app/fonts/*.ttf" ) ;
58+ var otfFiles = glob . sync ( " ./app/fonts/*.otf" ) ;
6059 var i , out ;
6160
62- for ( i = 0 ; i < ttfFiles . length ; i ++ ) {
63- out = ttfFiles [ i ] . replace ( ' ./app/' , ' ./nativescript-theme-core/' ) ;
61+ for ( i = 0 ; i < ttfFiles . length ; i ++ ) {
62+ out = ttfFiles [ i ] . replace ( " ./app/" , " ./nativescript-theme-core/" ) ;
6463 // Skip font Awesome
65- if ( out . indexOf ( 'fontawesome' ) !== - 1 ) { continue ; }
64+ if ( out . indexOf ( "fontawesome" ) !== - 1 ) {
65+ continue ;
66+ }
6667 fs . writeFileSync ( out , fs . readFileSync ( ttfFiles [ i ] ) ) ;
6768 }
6869
69- for ( i = 0 ; i < otfFiles . length ; i ++ ) {
70- out = otfFiles [ i ] . replace ( ' ./app/' , ' ./nativescript-theme-core/' ) ;
70+ for ( i = 0 ; i < otfFiles . length ; i ++ ) {
71+ out = otfFiles [ i ] . replace ( " ./app/" , " ./nativescript-theme-core/" ) ;
7172 // Skip font Awesome
72- if ( out . indexOf ( 'fontawesome' ) !== - 1 ) { continue ; }
73+ if ( out . indexOf ( "fontawesome" ) !== - 1 ) {
74+ continue ;
75+ }
7376 fs . writeFileSync ( out , fs . readFileSync ( otfFiles [ i ] ) ) ;
7477 }
7578
@@ -83,34 +86,34 @@ function copyFonts() {
8386 * Copy our SCSS files over
8487 */
8588function copySCSS ( ) {
86- var sassFilesPath = ' ./app/**/*.scss' ;
89+ var sassFilesPath = " ./app/**/*.scss" ;
8790 var sassFiles = glob . sync ( sassFilesPath ) . filter ( function ( filePath ) {
88- return filePath . indexOf ( "App_Resources" ) === - 1 && filePath . indexOf ( ' demo-styles' ) === - 1 ;
91+ return filePath . indexOf ( "App_Resources" ) === - 1 && filePath . indexOf ( " demo-styles" ) === - 1 ;
8992 } ) ;
9093
91- for ( var i = 0 ; i < sassFiles . length ; i ++ ) {
92- var out = sassFiles [ i ] . replace ( ' ./app/' , ' ./nativescript-theme-core/' ) ;
94+ for ( var i = 0 ; i < sassFiles . length ; i ++ ) {
95+ var out = sassFiles [ i ] . replace ( " ./app/" , " ./nativescript-theme-core/" ) ;
9396
94- var paths = sassFiles [ i ] . split ( '/' ) ;
95- // eliminate the ['.' and ' app' ]
97+ var paths = sassFiles [ i ] . split ( "/" ) ;
98+ // eliminate the ["." and " app" ]
9699 paths . shift ( ) ;
97100 paths . shift ( ) ;
98101
99102 if ( paths . length > 1 ) {
100- var path = ' ./nativescript-theme-core' ;
101- for ( var j = 0 ; j < paths . length - 1 ; j ++ ) {
102- path += '/' + paths [ j ] ;
103+ var path = " ./nativescript-theme-core" ;
104+ for ( var j = 0 ; j < paths . length - 1 ; j ++ ) {
105+ path += "/" + paths [ j ] ;
103106 if ( ! fs . existsSync ( path ) ) {
104107 fs . mkdirSync ( path ) ;
105108 }
106109 }
107110 }
108111
109- if ( sassFiles [ i ] . indexOf ( ' ./app/core.' ) > - 1 ) {
112+ if ( sassFiles [ i ] . indexOf ( " ./app/core." ) > - 1 ) {
110113 // print correct version on main files
111- var scss = fs . readFileSync ( sassFiles [ i ] , { encoding : ' utf8' } ) ;
114+ var scss = fs . readFileSync ( sassFiles [ i ] , { encoding : " utf8" } ) ;
112115 scss = printVersion ( scss ) ;
113- fs . writeFileSync ( out , scss , ' utf8' ) ;
116+ fs . writeFileSync ( out , scss , " utf8" ) ;
114117 } else {
115118 fs . writeFileSync ( out , fs . readFileSync ( sassFiles [ i ] ) ) ;
116119 }
@@ -124,23 +127,23 @@ function copySCSS() {
124127 */
125128function createCSSFromSCSS ( ) {
126129
127- var sassFilesPath = ' ./app/**/*.scss' ;
130+ var sassFilesPath = " ./app/**/*.scss" ;
128131 var sassImportPaths = [
129- ' ./app/' ,
130- ' ./node_modules/'
132+ " ./app/" ,
133+ " ./node_modules/"
131134 ] ;
132135
133136 var sassFiles = glob . sync ( sassFilesPath ) . filter ( function ( filePath ) {
134137 var path = filePath ;
135- var parts = path . split ( '/' ) ;
138+ var parts = path . split ( "/" ) ;
136139 var filename = parts [ parts . length - 1 ] ;
137- return path . indexOf ( "App_Resources" ) === - 1 && path . indexOf ( ' demo-styles' ) === - 1 && filename . indexOf ( "_" ) !== 0 && filename . indexOf ( ' app.' ) !== 0 ;
140+ return path . indexOf ( "App_Resources" ) === - 1 && path . indexOf ( " demo-styles" ) === - 1 && filename . indexOf ( "_" ) !== 0 && filename . indexOf ( " app." ) !== 0 ;
138141 } ) ;
139142
140143
141144 for ( var i = 0 ; i < sassFiles . length ; i ++ ) {
142145 // We only process open /core. files
143- if ( sassFiles [ i ] . indexOf ( ' /core.' ) === - 1 ) {
146+ if ( sassFiles [ i ] . indexOf ( " /core." ) === - 1 ) {
144147 continue ;
145148 }
146149 parseSass ( sassFiles [ i ] , sassImportPaths ) ;
@@ -153,18 +156,18 @@ function createCSSFromSCSS() {
153156 * @param importPaths - Other import paths
154157 */
155158function parseSass ( sassFile , importPaths ) {
156- var sassFileContent = fs . readFileSync ( sassFile , { encoding : ' utf8' } ) ;
157- var outputFile = ' nativescript-theme-core/css' ;
158- var offset = sassFile . lastIndexOf ( '/' ) ;
159+ var sassFileContent = fs . readFileSync ( sassFile , { encoding : " utf8" } ) ;
160+ var outputFile = " nativescript-theme-core/css" ;
161+ var offset = sassFile . lastIndexOf ( "/" ) ;
159162 outputFile += sassFile . substring ( offset ) ;
160- var cssFilePath = outputFile . replace ( ' .scss' , ' .css' ) ;
163+ var cssFilePath = outputFile . replace ( " .scss" , " .css" ) ;
161164
162165 // var output = sass.renderSync({
163- var output = sass . render ( {
166+ sass . render ( {
164167 data : sassFileContent ,
165168 includePaths : importPaths ,
166169 outFile : cssFilePath ,
167- outputStyle : ' compressed'
170+ outputStyle : " compressed"
168171 } , function ( error , result ) {
169172 if ( error ) {
170173 console . log ( error . status ) ;
@@ -177,7 +180,7 @@ function parseSass(sassFile, importPaths) {
177180 css = printVersion ( css ) ;
178181 // uncomment to debug builds
179182 // console.log(css);
180- fs . writeFileSync ( cssFilePath , css , ' utf8' ) ;
183+ fs . writeFileSync ( cssFilePath , css , " utf8" ) ;
181184
182185 // if build stats are ever desired
183186 // console.log(result.stats);
@@ -193,11 +196,11 @@ function parseSass(sassFile, importPaths) {
193196 */
194197function deleteFolderRecursive ( path ) {
195198 var files = [ ] ;
196- if ( fs . existsSync ( path ) ) {
199+ if ( fs . existsSync ( path ) ) {
197200 files = fs . readdirSync ( path ) ;
198- files . forEach ( function ( file , index ) {
201+ files . forEach ( function ( file ) {
199202 var curPath = path + "/" + file ;
200- if ( fs . lstatSync ( curPath ) . isDirectory ( ) ) { // recurse
203+ if ( fs . lstatSync ( curPath ) . isDirectory ( ) ) { // recurse
201204 deleteFolderRecursive ( curPath ) ;
202205 } else { // delete file
203206 fs . unlinkSync ( curPath ) ;
@@ -220,13 +223,13 @@ function copyFile(src, dest) {
220223 * Print correct version
221224 */
222225function printVersion ( css ) {
223- return css . replace ( versionPlaceholder , 'v' + version ) ;
226+ return css . replace ( versionPlaceholder , "v" + version ) ;
224227}
225228
226229/**
227230 * Get version from package
228231 */
229232function getVersion ( ) {
230- var packageJSON = require ( ' ../package.json' ) ;
233+ var packageJSON = require ( " ../package.json" ) ;
231234 return packageJSON ? packageJSON . version : null ;
232235}
0 commit comments