microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/ios/deviceDeployer.ts
32lines · 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, IXcodeProjFile} 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: IXcodeProjFile) => { |
| 21 | const pathToCompiledApp = path.join(this.projectRoot, "build", |
| 22 | "Build", "Products", "Debug-iphoneos", `${projectFile.projectName}.app`); |
| 23 | return new CommandExecutor(this.projectRoot) |
| 24 | .spawn("ideviceinstaller", ["-i", pathToCompiledApp]).catch((err) => { |
| 25 | if ((<any>err).errorCode === InternalErrorCode.CommandFailed && (<any>err).innerError.code === "ENOENT") { |
| 26 | throw ErrorHelper.getNestedError(err, InternalErrorCode.IDeviceInstallerNotFound); |
| 27 | } |
| 28 | throw err; |
| 29 | }); |
| 30 | }); |
| 31 | } |
| 32 | } |