microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
src/common/ios/xcodeproj.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 {ErrorHelper} from "../../common/error/errorHelper"; |
| 8 | import {Log} from "../../common/log/log"; |
| 9 | import {FileSystem} from "../../common/node/fileSystem"; |
| 10 | |
| 11 | import {TelemetryHelper} from "../../common/telemetryHelper"; |
| 12 | |
| 13 | export class Xcodeproj { |
| 14 | private nodeFileSystem: FileSystem; |
| 15 | |
| 16 | constructor({ |
| 17 | nodeFileSystem = new FileSystem(), |
| 18 | } = {}) { |
| 19 | this.nodeFileSystem = nodeFileSystem; |
| 20 | } |
| 21 | |
| 22 | public findXcodeprojFile(projectRoot: string): Q.Promise<string> { |
| 23 | return this.nodeFileSystem |
| 24 | .findFilesByExtension(path.join(projectRoot, "ios"), "xcodeproj") |
| 25 | .then((projectFiles: string[]) => { |
| 26 | if (projectFiles.length > 1) { |
| 27 | TelemetryHelper.sendSimpleEvent("multipleXcodeprojFound"); |
| 28 | Log.logWarning(ErrorHelper.getWarning(`More than one xcodeproj found. Using ${projectFiles[0]}`)); |
| 29 | } |
| 30 | return projectFiles[0]; |
| 31 | }); |
| 32 | } |
| 33 | } |