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

Commit 23feb8c

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fix livesync ios --emulator --watch if the file is not at project root level
Fixes NativeScript/nativescript-cli#776
1 parent 7732495 commit 23feb8c

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

declarations.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ interface IUsbLiveSyncServiceBase {
270270
notRunningiOSSimulatorAction: () => IFuture<void>,
271271
localProjectRootPath?: string,
272272
beforeLiveSyncAction?: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData) => IFuture<void>,
273-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>): IFuture<void>;
273+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>,
274+
iOSSimulatorRelativeToProjectBasePathAction?: (projectFile: string) => string): IFuture<void>;
274275
}
275276

276277
interface ISysInfoData {

definitions/mobile.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ declare module Mobile {
288288
interface IiOSSimulatorService extends IEmulatorPlatformServices {
289289
postDarwinNotification(notification: string): IFuture<void>;
290290
sync(appIdentifier: string, projectFilesPath: string, notRunningSimulatorAction: () => IFuture<void>): IFuture<void>;
291-
syncFiles(appIdentifier: string, projectFilesPath: string, projectFiles: string[], notRunningSimulatorAction: () => IFuture<void>): IFuture<void>;
291+
syncFiles(appIdentifier: string, projectFilesPath: string, projectFiles: string[], notRunningSimulatorAction: () => IFuture<void>, relativeToProjectBasePathAction?: (projectFile: string) => string): IFuture<void>;
292292
isSimulatorRunning(): IFuture<boolean>;
293293
}
294294

mobile/ios/ios-emulator-services.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ class IosEmulatorServices implements Mobile.IiOSSimulatorService {
6464
return this.syncCore(appIdentifier, notRunningSimulatorAction, syncAction);
6565
}
6666

67-
public syncFiles(appIdentifier: string, projectFilesPath: string, projectFiles: string[], notRunningSimulatorAction: () => IFuture<void>): IFuture<void> {
67+
public syncFiles(appIdentifier: string, projectFilesPath: string, projectFiles: string[], notRunningSimulatorAction: () => IFuture<void>, relativeToProjectBasePathAction?: (projectFile: string) => string): IFuture<void> {
6868
let syncAction = (applicationPath: string) => _.each(projectFiles, projectFile => {
69-
this.$logger.trace(`Transfering ${projectFile} to ${path.join(applicationPath, "app")}`);
70-
shell.cp("-Rf", projectFile, path.join(applicationPath, "app"));
69+
let destinationPath = path.join(applicationPath, relativeToProjectBasePathAction(projectFile));
70+
this.$logger.trace(`Transfering ${projectFile} to ${destinationPath}`);
71+
shell.cp("-Rf", projectFile, destinationPath);
7172
});
7273
return this.syncCore(appIdentifier, notRunningSimulatorAction, syncAction);
7374
}

services/usb-livesync-service-base.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
4545
notRunningiOSSimulatorAction: () => IFuture<void>,
4646
localProjectRootPath?: string,
4747
beforeLiveSyncAction?: (device: Mobile.IDevice, deviceAppData: Mobile.IDeviceAppData) => IFuture<void>,
48-
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>): IFuture<void> {
48+
beforeBatchLiveSyncAction?: (filePath: string) => IFuture<string>,
49+
iOSSimulatorRelativeToProjectBasePathAction?: (projectFile: string) => string): IFuture<void> {
4950
return (() => {
5051
let synciOSSimulator = this.$hostInfo.isDarwin ? this.$iOSEmulatorServices.isSimulatorRunning().wait() || (this.$options.emulator && platform.toLowerCase() === "ios") : false;
5152

@@ -70,7 +71,7 @@ export class UsbLiveSyncServiceBase implements IUsbLiveSyncServiceBase {
7071
if(event === "added" || event === "changed") {
7172
if(!_.contains(excludedProjectDirsAndFiles, filePath)) {
7273
if(synciOSSimulator) {
73-
__this.$dispatcher.dispatch(() => __this.$iOSEmulatorServices.syncFiles(appIdentifier, projectFilesPath, [filePath], notRunningiOSSimulatorAction));
74+
__this.$dispatcher.dispatch(() => __this.$iOSEmulatorServices.syncFiles(appIdentifier, projectFilesPath, [filePath], notRunningiOSSimulatorAction, iOSSimulatorRelativeToProjectBasePathAction));
7475
}
7576

7677
if(!__this.$options.emulator || platform.toLowerCase() === "android") {

0 commit comments

Comments
 (0)