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