microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.3.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/common/ios/xcodeproj.ts

46lines · modeblame

afc46a73Jimmy Thomson10 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
c4a42a32Jimmy Thomson9 years ago4import * as path from "path";
afc46a73Jimmy Thomson10 years ago5import * as Q from "q";
6
db80cd4eJimmy Thomson10 years ago7import {FileSystem} from "../../common/node/fileSystem";
afc46a73Jimmy Thomson10 years ago8
c4a42a32Jimmy Thomson9 years ago9export interface IXcodeProjFile {
81d6e05bJimmy Thomson9 years ago10fileName: string;
11fileType: string;
eec73ab5Jimmy Thomson9 years ago12projectName: string;
c4a42a32Jimmy Thomson9 years ago13}
14
afc46a73Jimmy Thomson10 years ago15export class Xcodeproj {
81226dceJimmy Thomson10 years ago16private nodeFileSystem: FileSystem;
17
18constructor({
cdf34447digeff10 years ago19nodeFileSystem = new FileSystem(),
81226dceJimmy Thomson10 years ago20} = {}) {
21this.nodeFileSystem = nodeFileSystem;
22}
23
c4a42a32Jimmy Thomson9 years ago24public findXcodeprojFile(projectRoot: string): Q.Promise<IXcodeProjFile> {
81226dceJimmy Thomson10 years ago25return this.nodeFileSystem
c4a42a32Jimmy Thomson9 years ago26.readDir(projectRoot)
27.then((files: string[]): IXcodeProjFile => {
28const sorted = files.sort();
29const candidate = sorted.find((file: string) =>
30[".xcodeproj", ".xcworkspace"].indexOf(path.extname(file)) !== -1
31);
32if (!candidate) {
33throw new Error("Unable to find any xcodeproj or xcworkspace files.");
34}
35
81d6e05bJimmy Thomson9 years ago36const fileName = path.join(projectRoot, candidate);
37const fileType = path.extname(candidate);
38const projectName = path.basename(candidate, fileType);
c4a42a32Jimmy Thomson9 years ago39return {
81d6e05bJimmy Thomson9 years ago40fileName,
41fileType,
eec73ab5Jimmy Thomson9 years ago42projectName,
43};
afc46a73Jimmy Thomson10 years ago44});
45}
46}