microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/ios/deviceDeployer.ts
33lines · 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"; |
a9d96b7cdigeff10 years ago | 8 | import {Xcodeproj} 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) { | |
398e2b0bMark Oswald10 years ago | 16 | this.projectRoot = projectRoot.match(/(.*)ios\/?$/) ? projectRoot.match(/(.*)ios\/?$/)[1] : projectRoot; |
488f1908Jimmy Thomson10 years ago | 17 | } |
| 18 | | |
| 19 | public deploy(): Q.Promise<void> { | |
bc96b26bJimmy Thomson10 years ago | 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) | |
323a3cc0Meena Kunnathur Balakrishnan10 years ago | 25 | .spawn("ideviceinstaller", ["-i", pathToCompiledApp]).catch((err) => { |
cb6d0922digeff10 years ago | 26 | if ((<any>err).code === "ENOENT") { |
190e393cMeena Kunnathur Balakrishnan10 years ago | 27 | throw ErrorHelper.getNestedError(err, InternalErrorCode.IDeviceInstallerNotFound); |
bc96b26bJimmy Thomson10 years ago | 28 | } |
| 29 | throw err; | |
| 30 | }); | |
| 31 | }); | |
488f1908Jimmy Thomson10 years ago | 32 | } |
| 33 | } |