@@ -4,24 +4,41 @@ var glob = require('glob');
4
4
var Promise = require ( 'bluebird' ) ;
5
5
6
6
// Clean-up files from compiled app packages
7
- module . exports = function ( $ logger, $ projectData, $usbLiveSyncService ) {
7
+ module . exports = function ( logger , platformsData , projectData , hookArgs ) {
8
8
// delete all scss files from compiled sources
9
- var platformsData = $injector . resolve ( 'platformsData' ) ;
10
- return Promise . each ( platformsData . platformsNames , function ( platform ) {
9
+
10
+ // Don't include .SCSS files in LiveSync -- only sync CSS files
11
+ if ( hookArgs . filesToSync !== undefined ) {
12
+ hookArgs . filesToSync . forEach ( function ( file , index ) {
13
+ if ( file . indexOf ( ".scss" ) !== - 1 ) {
14
+ // Remove the .SCSS file from LiveSync operation
15
+ hookArgs . filesToSync . splice ( index , 1 ) ;
16
+ }
17
+ } ) ;
18
+ }
19
+
20
+ var platformData = platformsData . getPlatformData ( hookArgs . platform . toLowerCase ( ) ) ;
21
+
22
+ return new Promise ( function ( resolve , reject ) {
11
23
// Remove node_sass directory from compiled output
12
- var nodeSassPath = path . join ( platformsData . getPlatformData ( platform ) . appDestinationDirectoryPath , 'app/tns_modules/node-sass/' ) ;
24
+ var nodeSassPath = path . join ( platformData . appDestinationDirectoryPath , 'app/tns_modules/node-sass/' ) ;
13
25
deleteFolderRecursive ( nodeSassPath ) ;
14
26
15
27
// Find and remove unnecessary SCSS files from iOS and Android app packages
16
- var sassFilesPath = path . join ( platformsData . getPlatformData ( platform ) . appDestinationDirectoryPath , 'app/**/*.scss' ) ;
28
+ var sassFilesPath = path . join ( platformData . appDestinationDirectoryPath , 'app/**/*.scss' ) ;
17
29
var sassFiles = glob . sync ( sassFilesPath ) . filter ( function ( filePath ) {
18
30
var path = filePath ;
19
31
var parts = path . split ( '/' ) ;
20
32
var filename = parts [ parts . length - 1 ] ;
21
33
return path . indexOf ( "App_Resources" ) === - 1 ;
22
34
} ) ;
23
- return Promise . each ( sassFiles , function ( sassFile ) {
35
+
36
+ Promise . each ( sassFiles , function ( sassFile ) {
24
37
return fs . unlinkSync ( sassFile ) ;
38
+ } )
39
+ . then ( function ( ) {
40
+ console . log ( "All SASS source files removed from app package" ) ;
41
+ resolve ( ) ;
25
42
} ) ;
26
43
} ) ;
27
44
}
@@ -39,4 +56,4 @@ var deleteFolderRecursive = function(filepath) {
39
56
} ) ;
40
57
return fs . rmdirSync ( filepath ) ;
41
58
}
42
- } ;
59
+ } ;
0 commit comments