11/*************************************************************************************
22 * Licensed under the APACHE license
33 *
4- * Version 0.0.1 Nathan@master-technology.com
4+ * Version 0.0.3 Nathan@master-technology.com
55 ************************************************************************************/
66"use strict" ;
77
@@ -39,17 +39,30 @@ copyFolder(cwd+"css", appDir+"css");
3939
4040// Update our main app.css to import the light theme
4141if ( fs . existsSync ( appDir + "app.css" ) ) {
42+ var BOM = '' ;
4243 var cssData = fs . readFileSync ( appDir + "app.css" ) . toString ( ) ;
44+
45+ // Strip the BOM at the beginning of the file
46+ if ( cssData . charCodeAt ( 0 ) === 0xFEFF ) {
47+ // Newer NodeJS
48+ BOM = String . fromCharCode ( 0xFEFF ) ;
49+ cssData = cssData . slice ( 1 ) ;
50+ } else if ( cssData [ 0 ] === 0xEF && cssData [ 1 ] === 0xBB && cssData [ 2 ] === 0xBF ) {
51+ // Older NodeJS
52+ BOM = String . fromCharCode ( 0xEF ) + String . fromCharCode ( 0xBB ) + String . fromCharCode ( 0xBF ) ;
53+ cssData = cssData . slice ( 3 ) ;
54+ }
55+
4356 if ( cssData . indexOf ( "@import '~/css/core." ) === - 1 ) {
44- cssData = "@import '~/css/core.light.css'; \r\n\r\n" + cssData ;
57+ cssData = BOM + "@import '~/css/core.light.css'; \r\n\r\n" + cssData ;
4558 fs . writeFileSync ( appDir + "app.css" , cssData ) ;
4659 }
4760}
4861
4962// ------------------------------------------------------
5063// Handle the FONTS files
5164// ------------------------------------------------------
52- copyFolder ( cwd + "fonts" , appDir + "fonts" ) ;
65+ copyFolder ( cwd + "fonts" , appDir + "fonts" ) ;
5366
5467// ------------------------------------------------------
5568// Handle the SCSS files
@@ -72,19 +85,19 @@ if (hasSCSS) {
7285 * @param dest (string) - Destination folder
7386 */
7487function copyFolder ( src , dest ) {
75- try {
88+ // No source Folder exists, can't copy it!
89+ if ( ! fs . existsSync ( src ) ) { return false ; }
90+
7691 var files = fs . readdirSync ( src ) ;
77- files . forEach ( function ( file ) {
78- var curPath = src + "/" + file ;
79- if ( fs . lstatSync ( curPath ) . isDirectory ( ) ) { // check to see if we need to recurse
80- copyFolder ( curPath , dest + "/" + file ) ;
81- } else { // copy file
82- copyFile ( src , dest , file ) ;
83- }
92+ files . forEach ( function ( file ) {
93+ var curPath = src + "/" + file ;
94+ if ( fs . lstatSync ( curPath ) . isDirectory ( ) ) { // check to see if we need to recurse
95+ copyFolder ( curPath , dest + "/" + file ) ;
96+ } else { // copy file
97+ copyFile ( src , dest , file ) ;
98+ }
8499 } ) ;
85- } catch ( err ) {
86- console . log ( 'Skipping ' + src + ' copy.' ) ;
87- }
100+ return true ;
88101}
89102
90103/**
0 commit comments