nativescript
Version:
Command-line interface for building NativeScript projects
50 lines • 2.41 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DevicePathProvider = void 0;
const helpers_1 = require("./common/helpers");
const constants_1 = require("./constants");
const constants_2 = require("./common/constants");
const path = require("path");
const yok_1 = require("./common/yok");
class DevicePathProvider {
constructor($mobileHelper, $iOSSimResolver, $errors) {
this.$mobileHelper = $mobileHelper;
this.$iOSSimResolver = $iOSSimResolver;
this.$errors = $errors;
}
async getDeviceProjectRootPath(device, options) {
let projectRoot = "";
if (this.$mobileHelper.isApplePlatform(device.deviceInfo.platform)) {
projectRoot = device.isEmulator
? await this.$iOSSimResolver.iOSSim.getApplicationPath(device.deviceInfo.identifier, options.appIdentifier)
: constants_2.LiveSyncPaths.IOS_DEVICE_PROJECT_ROOT_PATH;
if (!projectRoot) {
this.$errors.fail("Unable to get application path on device.");
}
if (!options.getDirname) {
projectRoot = path.join(projectRoot, constants_1.APP_FOLDER_NAME);
}
}
else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
projectRoot = `${constants_2.LiveSyncPaths.ANDROID_TMP_DIR_NAME}/${options.appIdentifier}`;
if (!options.getDirname) {
const hashService = (device).fileSystem.getDeviceHashService(options.appIdentifier);
const hashFile = await hashService.doesShasumFileExistsOnDevice();
const syncFolderName = options.watch || hashFile
? constants_2.LiveSyncPaths.SYNC_DIR_NAME
: constants_2.LiveSyncPaths.FULLSYNC_DIR_NAME;
projectRoot = path.join(projectRoot, syncFolderName);
}
}
return (0, helpers_1.fromWindowsRelativePathToUnix)(projectRoot);
}
getDeviceSyncZipPath(device) {
return this.$mobileHelper.isApplePlatform(device.deviceInfo.platform) &&
!device.isEmulator
? constants_2.LiveSyncPaths.IOS_DEVICE_SYNC_ZIP_PATH
: undefined;
}
}
exports.DevicePathProvider = DevicePathProvider;
yok_1.injector.register("devicePathProvider", DevicePathProvider);
//# sourceMappingURL=device-path-provider.js.map
;