@@ -6,9 +6,15 @@ import * as shell from "shelljs";
6
6
import * as constants from "../constants" ;
7
7
import * as helpers from "../common/helpers" ;
8
8
import * as semver from "semver" ;
9
+ import * as minimatch from "minimatch" ;
10
+ import Future = require( "fibers/future" ) ;
9
11
10
12
export class PlatformService implements IPlatformService {
11
13
private static TNS_MODULES_FOLDER_NAME = "tns_modules" ;
14
+ private static EXCLUDE_FILES_PATTERN = [
15
+ "**/*.js.map" ,
16
+ "**/*.ts"
17
+ ] ;
12
18
13
19
constructor ( private $devicesService : Mobile . IDevicesService ,
14
20
private $errors : IErrors ,
@@ -174,22 +180,26 @@ export class PlatformService implements IPlatformService {
174
180
. value ( ) ;
175
181
176
182
// Copy all files from app dir, but make sure to exclude tns_modules
177
- let sourceFiles = this . $fs . readDirectory ( appSourceDirectoryPath ) . wait ( ) ;
183
+ let sourceFiles = this . $fs . enumerateFilesInDirectorySync ( appSourceDirectoryPath ) ;
178
184
179
185
if ( this . $options . release ) {
180
186
sourceFiles = sourceFiles . filter ( source => source !== 'tests' ) ;
181
187
}
182
188
183
- let hasTnsModulesInAppFolder = _ . contains ( sourceFiles , constants . TNS_MODULES_FOLDER_NAME ) ;
189
+ let hasTnsModulesInAppFolder = this . $fs . exists ( path . join ( appSourceDirectoryPath , constants . TNS_MODULES_FOLDER_NAME ) ) . wait ( ) ;
184
190
if ( hasTnsModulesInAppFolder && this . $projectData . dependencies && this . $projectData . dependencies [ constants . TNS_CORE_MODULES_NAME ] ) {
185
191
this . $logger . warn ( "You have tns_modules dir in your app folder and tns-core-modules in your package.json file. Tns_modules dir in your app folder will not be used and you can safely remove it." ) ;
186
- sourceFiles . filter ( source => source !== constants . TNS_MODULES_FOLDER_NAME )
187
- . map ( source => path . join ( appSourceDirectoryPath , source ) )
188
- . forEach ( source => shell . cp ( "-Rf" , source , appDestinationDirectoryPath ) ) ;
189
- } else {
190
- shell . cp ( "-Rf" , path . join ( appSourceDirectoryPath , "*" ) , appDestinationDirectoryPath ) ;
192
+ sourceFiles = sourceFiles . filter ( source => ! minimatch ( source , `**/${ constants . TNS_MODULES_FOLDER_NAME } /**` , { nocase : true } ) ) ;
191
193
}
192
194
195
+ // Remove .ts and .js.map files
196
+ PlatformService . EXCLUDE_FILES_PATTERN . forEach ( pattern => sourceFiles = sourceFiles . filter ( file => ! minimatch ( file , pattern , { nocase : true } ) ) ) ;
197
+ let copyFileFutures = sourceFiles . map ( source => {
198
+ let destinationFile = path . join ( appDestinationDirectoryPath , path . relative ( appSourceDirectoryPath , source ) ) ;
199
+ return this . $fs . copyFile ( source , destinationFile ) ;
200
+ } ) ;
201
+ Future . wait ( copyFileFutures ) ;
202
+
193
203
// Copy App_Resources to project root folder
194
204
this . $fs . ensureDirectoryExists ( platformData . platformProjectService . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) ) . wait ( ) ; // Should be deleted
195
205
let appResourcesDirectoryPath = path . join ( appDestinationDirectoryPath , constants . APP_RESOURCES_FOLDER_NAME ) ;
0 commit comments