@@ -3,10 +3,15 @@ var path = require('path');
3
3
var glob = require ( 'glob' ) ;
4
4
var Promise = require ( 'bluebird' ) ;
5
5
6
+ // Clean-up files from compiled app packages
6
7
module . exports = function ( $logger , $projectData , $usbLiveSyncService ) {
7
8
// delete all scss files from compiled sources
8
9
var platformsData = $injector . resolve ( 'platformsData' ) ;
9
10
return Promise . each ( platformsData . platformsNames , function ( platform ) {
11
+ // Remove node_sass directory from compiled output
12
+ var nodeSassPath = path . join ( platformsData . getPlatformData ( platform ) . appDestinationDirectoryPath , 'app/tns_modules/node-sass/' ) ;
13
+ deleteFolderRecursive ( nodeSassPath ) ;
14
+
10
15
// Find and remove unnecessary SCSS files from iOS and Android app packages
11
16
var sassFilesPath = path . join ( platformsData . getPlatformData ( platform ) . appDestinationDirectoryPath , 'app/**/*.scss' ) ;
12
17
var sassFiles = glob . sync ( sassFilesPath ) . filter ( function ( filePath ) {
@@ -19,4 +24,19 @@ module.exports = function ($logger, $projectData, $usbLiveSyncService) {
19
24
return fs . unlinkSync ( sassFile ) ;
20
25
} ) ;
21
26
} ) ;
22
- }
27
+ }
28
+
29
+ // Utility to delete non-empty folder recursively
30
+ var deleteFolderRecursive = function ( filepath ) {
31
+ if ( fs . existsSync ( filepath ) ) {
32
+ fs . readdirSync ( filepath ) . forEach ( function ( file , index ) {
33
+ var curPath = path . join ( filepath , file ) ;
34
+ if ( fs . lstatSync ( curPath ) . isDirectory ( ) ) { // recurse
35
+ deleteFolderRecursive ( curPath ) ;
36
+ } else { // delete file
37
+ fs . unlinkSync ( curPath ) ;
38
+ }
39
+ } ) ;
40
+ return fs . rmdirSync ( filepath ) ;
41
+ }
42
+ } ;
0 commit comments