microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/ios/deviceDeployer.ts
33lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | |
| 4 | import * as path from "path"; |
| 5 | import * as Q from "q"; |
| 6 | |
| 7 | import {CommandExecutor} from "../../common/commandExecutor"; |
| 8 | import {Xcodeproj} from "../../common/ios/xcodeproj"; |
| 9 | import {ErrorHelper} from "../../common/error/errorHelper"; |
| 10 | import {InternalErrorCode} from "../../common/error/internalErrorCode"; |
| 11 | |
| 12 | export class DeviceDeployer { |
| 13 | private projectRoot: string; |
| 14 | |
| 15 | constructor(projectRoot: string) { |
| 16 | this.projectRoot = projectRoot; |
| 17 | } |
| 18 | |
| 19 | public deploy(): Q.Promise<void> { |
| 20 | return new Xcodeproj().findXcodeprojFile(this.projectRoot).then((projectFile: string) => { |
| 21 | const projectName = path.basename(projectFile, path.extname(projectFile)); |
| 22 | const pathToCompiledApp = path.join(this.projectRoot, "ios", "build", |
| 23 | "Build", "Products", "Debug-iphoneos", `${projectName}.app`); |
| 24 | return new CommandExecutor(this.projectRoot) |
| 25 | .spawn("ideviceinstaller", ["-i", pathToCompiledApp]).catch((err) => { |
| 26 | if ((<any>err).code === "ENOENT") { |
| 27 | throw ErrorHelper.getNestedError(err, InternalErrorCode.IDeviceInstallerNotFound); |
| 28 | } |
| 29 | throw err; |
| 30 | }); |
| 31 | }); |
| 32 | } |
| 33 | } |