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 {Log} from "../../common/log"; |
| 9 | import {Xcodeproj} from "../../common/ios/xcodeproj"; |
| 10 | |
| 11 | export class DeviceDeployer { |
| 12 | private projectRoot: string; |
| 13 | |
| 14 | constructor(projectRoot: string) { |
| 15 | this.projectRoot = projectRoot; |
| 16 | } |
| 17 | |
| 18 | public deploy(): Q.Promise<void> { |
| 19 | return new Xcodeproj().findXcodeprojFile(this.projectRoot).then((projectFile: string) => { |
| 20 | const projectName = path.basename(projectFile, path.extname(projectFile)); |
| 21 | const pathToCompiledApp = path.join(this.projectRoot, "ios", "build", |
| 22 | "Build", "Products", "Debug-iphoneos", `${projectName}.app`); |
| 23 | return new CommandExecutor(this.projectRoot) |
| 24 | .spawnAndWaitForCompletion("ideviceinstaller", ["-i", pathToCompiledApp]).catch((err) => { |
| 25 | if (err.code === "ENOENT") { |
| 26 | Log.logError("Unable to find ideviceinstaller. Please make sure to install Homebrew (http://brew.sh) and then 'brew install ideviceinstaller'"); |
| 27 | } |
| 28 | throw err; |
| 29 | }); |
| 30 | }); |
| 31 | } |
| 32 | } |