@@ -27,7 +27,7 @@ export class ProjectFilesManager implements IProjectFilesManager {
27
27
}
28
28
29
29
public createLocalToDevicePaths ( deviceAppData : Mobile . IDeviceAppData , projectFilesPath : string , files ?: string [ ] , excludedProjectDirsAndFiles ?: string [ ] ) : Mobile . ILocalToDevicePathData [ ] {
30
- files = files || this . getProjectFiles ( projectFilesPath , excludedProjectDirsAndFiles , null , { enumerateDirectories : true } ) ;
30
+ files = files || this . getProjectFiles ( projectFilesPath , excludedProjectDirsAndFiles , null , { enumerateDirectories : true } ) ;
31
31
let localToDevicePaths = files
32
32
. map ( projectFile => this . $projectFilesProvider . getProjectFileInfo ( projectFile , deviceAppData . platform ) )
33
33
. filter ( projectFileInfo => projectFileInfo . shouldIncludeFile )
@@ -44,9 +44,9 @@ export class ProjectFilesManager implements IProjectFilesManager {
44
44
_ . each ( contents , fileName => {
45
45
let filePath = path . join ( directoryPath , fileName ) ;
46
46
let fsStat = this . $fs . getFsStats ( filePath ) . wait ( ) ;
47
- if ( fsStat . isDirectory ( ) && ! _ . contains ( excludedDirs , fileName ) ) {
47
+ if ( fsStat . isDirectory ( ) && ! _ . contains ( excludedDirs , fileName ) ) {
48
48
this . processPlatformSpecificFilesCore ( platform , this . $fs . enumerateFilesInDirectorySync ( filePath ) ) . wait ( ) ;
49
- } else if ( fsStat . isFile ( ) ) {
49
+ } else if ( fsStat . isFile ( ) ) {
50
50
files . push ( filePath ) ;
51
51
}
52
52
} ) ;
@@ -63,10 +63,28 @@ export class ProjectFilesManager implements IProjectFilesManager {
63
63
if ( ! projectFileInfo . shouldIncludeFile ) {
64
64
this . $fs . deleteFile ( filePath ) . wait ( ) ;
65
65
} else if ( projectFileInfo . onDeviceFileName ) {
66
- this . $fs . rename ( filePath , path . join ( path . dirname ( filePath ) , projectFileInfo . onDeviceFileName ) ) . wait ( ) ;
66
+ let onDeviceFilePath = path . join ( path . dirname ( filePath ) , projectFileInfo . onDeviceFileName ) ;
67
+
68
+ // Fix .js.map entries
69
+ let extension = path . extname ( projectFileInfo . onDeviceFileName ) ;
70
+ if ( ( extension === ".js" || extension === ".map" ) && onDeviceFilePath !== filePath ) {
71
+ let oldName = this . getFileName ( filePath , extension ) ;
72
+ let newName = this . getFileName ( projectFileInfo . onDeviceFileName , extension ) ;
73
+
74
+ let fileContent = this . $fs . readText ( filePath ) . wait ( ) ;
75
+ fileContent = fileContent . replace ( new RegExp ( oldName , 'g' ) , newName ) ;
76
+ this . $fs . writeFile ( filePath , fileContent ) . wait ( ) ;
77
+ }
78
+
79
+ // Rename the file
80
+ this . $fs . rename ( filePath , onDeviceFilePath ) . wait ( ) ;
67
81
}
68
82
} ) ;
69
83
} ) . future < void > ( ) ( ) ;
70
84
}
85
+
86
+ private getFileName ( filePath : string , extension : string ) : string {
87
+ return path . basename ( filePath . replace ( extension === ".map" ? ".js.map" : ".js" , "" ) ) ;
88
+ }
71
89
}
72
90
$injector . register ( "projectFilesManager" , ProjectFilesManager ) ;
0 commit comments