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

Commit 6d52c6a

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fix ENAMETOOLONG on windows
1 parent 7116d9c commit 6d52c6a

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

definitions/mobile.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ declare module Mobile {
8585
transferFiles(appIdentifier: string, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void>;
8686
transferDirectory(deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[], projectFilesPath: string): IFuture<void>;
8787
transferFile?(localFilePath: string, deviceFilePath: string): IFuture<void>;
88+
createFileOnDevice?(deviceFilePath: string, fileContent: string): IFuture<void>;
8889
}
8990

9091
interface IAndroidDebugBridge {

mobile/android/android-device-file-system.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
"use strict";
33

44
import * as path from "path";
5+
import * as temp from "temp";
56
import future = require("fibers/future");
67

78
export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem {
89
constructor(private adb: Mobile.IAndroidDebugBridge,
910
private identifier: string,
1011
private $fs: IFileSystem,
1112
private $logger: ILogger,
12-
private $deviceAppDataFactory: Mobile.IDeviceAppDataFactory) { }
13+
private $deviceAppDataFactory: Mobile.IDeviceAppDataFactory,
14+
private $mobileHelper: Mobile.IMobileHelper) { }
1315

1416
public listFiles(devicePath: string): IFuture<void> {
1517
return future.fromResult();
@@ -45,8 +47,10 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem {
4547
return (() => {
4648
this.adb.executeCommand(["push", projectFilesPath, deviceAppData.deviceProjectRootPath]).wait();
4749

48-
let command = _.map(localToDevicePaths, (localToDevicePathData) => localToDevicePathData.getDevicePath()).join(" ");
49-
this.adb.executeCommand(["chmod", "0777", command]).wait();
50+
let command = _.map(localToDevicePaths, (localToDevicePathData) => `"${localToDevicePathData.getDevicePath()}"`).join(" ");
51+
let commandsDeviceFilePath = this.$mobileHelper.buildDevicePath(deviceAppData.deviceProjectRootPath, "nativescript.commands.sh");
52+
this.createFileOnDevice(commandsDeviceFilePath, command).wait();
53+
this.adb.executeShellCommand([commandsDeviceFilePath]).wait();
5054
}).future<void>()();
5155
}
5256

@@ -61,4 +65,22 @@ export class AndroidDeviceFileSystem implements Mobile.IDeviceFileSystem {
6165
}
6266
}).future<void>()();
6367
}
68+
69+
public createFileOnDevice(deviceFilePath: string, fileContent: string): IFuture<void> {
70+
return (() => {
71+
let hostTmpDir = this.getTempDir();
72+
let commandsFileHostPath = path.join(hostTmpDir, "temp.commands.file");
73+
this.$fs.writeFile(commandsFileHostPath, fileContent).wait();
74+
75+
// copy it to the device
76+
this.transferFile(commandsFileHostPath, deviceFilePath).wait();
77+
this.adb.executeShellCommand(["chmod", "0777", deviceFilePath]).wait();
78+
}).future<void>()();
79+
}
80+
81+
private getTempDir(): string {
82+
temp.track();
83+
return temp.mkdirSync("application-");
84+
}
85+
6486
}

mobile/android/android-livesync-service.ts

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
///<reference path="../../.d.ts"/>
22
"use strict";
33

4-
import * as path from "path";
5-
import * as temp from "temp";
6-
74
class LiveSyncCommands {
85
public static DeployProjectCommand(liveSyncUrl: string): string {
96
return `DeployProject ${liveSyncUrl} \r`;
@@ -43,19 +40,6 @@ export class AndroidLiveSyncService implements Mobile.IAndroidLiveSyncService {
4340
}
4441

4542
public createCommandsFileOnDevice(commandsFileDevicePath: string, commands: string[]): IFuture<void> {
46-
return (() => {
47-
let hostTmpDir = this.getTempDir();
48-
let commandsFileHostPath = path.join(hostTmpDir, AndroidLiveSyncService.COMMANDS_FILE);
49-
this.$fs.writeFile(commandsFileHostPath, commands.join("\n")).wait();
50-
51-
// copy it to the device
52-
this.device.fileSystem.transferFile(commandsFileHostPath, commandsFileDevicePath).wait();
53-
this.device.adb.executeShellCommand(["chmod", "0777", `${commandsFileDevicePath}`]).wait();
54-
}).future<void>()();
55-
}
56-
57-
private getTempDir(): string {
58-
temp.track();
59-
return temp.mkdirSync("ab-");
43+
return this.device.fileSystem.createFileOnDevice(commandsFileDevicePath, commands.join("\n"));
6044
}
6145
}

0 commit comments

Comments
 (0)