Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 26b06fc

Browse files
committed
Fix .js.map entries
1 parent 693bab9 commit 26b06fc

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

services/project-files-manager.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class ProjectFilesManager implements IProjectFilesManager {
2727
}
2828

2929
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 });
3131
let localToDevicePaths = files
3232
.map(projectFile => this.$projectFilesProvider.getProjectFileInfo(projectFile, deviceAppData.platform))
3333
.filter(projectFileInfo => projectFileInfo.shouldIncludeFile)
@@ -44,9 +44,9 @@ export class ProjectFilesManager implements IProjectFilesManager {
4444
_.each(contents, fileName => {
4545
let filePath = path.join(directoryPath, fileName);
4646
let fsStat = this.$fs.getFsStats(filePath).wait();
47-
if(fsStat.isDirectory() && !_.contains(excludedDirs, fileName)) {
47+
if (fsStat.isDirectory() && !_.contains(excludedDirs, fileName)) {
4848
this.processPlatformSpecificFilesCore(platform, this.$fs.enumerateFilesInDirectorySync(filePath)).wait();
49-
} else if(fsStat.isFile()) {
49+
} else if (fsStat.isFile()) {
5050
files.push(filePath);
5151
}
5252
});
@@ -63,10 +63,28 @@ export class ProjectFilesManager implements IProjectFilesManager {
6363
if (!projectFileInfo.shouldIncludeFile) {
6464
this.$fs.deleteFile(filePath).wait();
6565
} 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)}.${platform}`;
72+
let newName = this.getFileName(projectFileInfo.onDeviceFileName);
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();
6781
}
6882
});
6983
}).future<void>()();
7084
}
85+
86+
private getFileName(filePath: string): string {
87+
return path.basename(filePath).split(".")[0];
88+
}
7189
}
7290
$injector.register("projectFilesManager", ProjectFilesManager);

0 commit comments

Comments
 (0)