Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

fix getxcodeversion usage #996

Merged
merged 3 commits into from
Aug 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions services/xcode-select-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export class XcodeSelectService implements IXcodeSelectService {
@cache()
public async getXcodeVersion(): Promise<IVersionData> {
let sysInfoBase = this.$injector.resolve("sysInfoBase");
let xcodeVer = await sysInfoBase.getXCodeVersion(),
xcodeVersionMatch = xcodeVer.match(/Xcode (.*)/),
let xcodeVer = await sysInfoBase.getXCodeVersion();
if (!xcodeVer) {
this.$errors.failWithoutHelp("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
}

let xcodeVersionMatch = xcodeVer.match(/Xcode (.*)/),
xcodeVersionGroup = xcodeVersionMatch && xcodeVersionMatch[1],
xcodeVersionSplit = xcodeVersionGroup && xcodeVersionGroup.split(".");

Expand Down
8 changes: 2 additions & 6 deletions sys-info-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ export class SysInfoBase implements ISysInfo {
private xCodeVerCache: string = null;
public async getXCodeVersion(): Promise<string> {
if (!this.xCodeVerCache) {
try {
this.xCodeVerCache = this.$hostInfo.isDarwin ? await this.exec("xcodebuild -version") : null;
} catch (e) {
this.$logger.trace(`Command "xcodebuild -version" failed: ${e}`);
this.xCodeVerCache = null;
}
this.xCodeVerCache = this.$hostInfo.isDarwin ? await this.exec("xcodebuild -version") : null;
}

return this.xCodeVerCache;
Expand Down Expand Up @@ -207,6 +202,7 @@ export class SysInfoBase implements ISysInfo {
}
} catch (e) {
// if we got an error, assume not working
this.$logger.trace(`Error while executing ${cmd}: ${e.message}`);
}

return null;
Expand Down