Skip to content

Commit a6b144f

Browse files
author
Fatme
authored
Merge pull request #31 from NativeScript/fatme/fix-cocoapods
Fix isCocoaPodsWorkingCorrectly
2 parents fd56e44 + a13706a commit a6b144f

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ before_script:
77
- npm install grunt-cli
88
- npm install
99
script:
10+
- node_modules/.bin/grunt lint
1011
- node_modules/.bin/grunt pack --no-color

lib/doctor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Constants } from "./constants";
2-
import { EOL, platform } from "os";
2+
import { EOL } from "os";
33
import { HostInfo } from "./host-info";
44
import { AndroidLocalBuildRequirements } from "./local-build-requirements/android-local-build-requirements";
55
import { IosLocalBuildRequirements } from "./local-build-requirements/ios-local-build-requirements";
@@ -198,7 +198,7 @@ export class Doctor implements NativeScriptDoctor.IDoctor {
198198
additionalInformation: data.additionalInformation,
199199
platforms: data.platforms,
200200
type: Constants.WARNING_TYPE_NAME
201-
}
201+
};
202202
}
203203

204204
return {

lib/sys-info.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
235235
public isCocoaPodsWorkingCorrectly(): Promise<boolean> {
236236
return this.getValueForProperty(() => this.isCocoaPodsWorkingCorrectlyCache, async (): Promise<boolean> => {
237237
if (this.hostInfo.isDarwin) {
238+
if (!this.fileSystem.exists(path.join(osenv.home(), ".cocoapods"))) {
239+
return true;
240+
}
238241
temp.track();
239242
const tempDirectory = temp.mkdirSync("nativescript-check-cocoapods");
240243
const pathToXCodeProjectZip = path.join(__dirname, "..", "resources", "cocoapods-verification", "cocoapods.zip");
@@ -248,7 +251,7 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
248251
if (spawnResult.exitCode) {
249252
return false;
250253
} else {
251-
return await this.fileSystem.exists(path.join(xcodeProjectDir, "cocoapods.xcworkspace"));
254+
return this.fileSystem.exists(path.join(xcodeProjectDir, "cocoapods.xcworkspace"));
252255
}
253256
} catch (err) {
254257
return null;

test/sys-info.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { ChildProcess } from "../lib/wrappers/child-process";
88
const JavaHomeName = "JAVA_HOME";
99
const AndroidHomeName = "ANDROID_HOME";
1010
const PROGRAM_FILES = "ProgramFiles";
11+
const PROGRAM_FILES_X86 = "ProgramFiles(x86)";
12+
const LOCAL_APP_DATA = "LOCALAPPDATA";
1113
const PROGRAM_FILES_ENV_PATH = "C:\\Program Files";
14+
const PROGRAM_FILEX_X86_ENV_PATH = "C:\\Program Files(x86)";
15+
const LOCAL_APP_DATA_ENV_PATH = "C:\\username\\localappdata";
1216

1317
interface IChildProcessResultDescription {
1418
result?: any;
@@ -145,7 +149,7 @@ function mockSysInfo(childProcessResult: IChildProcessResults, hostInfoOptions?:
145149
};
146150

147151
const fileSystem: any = {
148-
exists: () => Promise.resolve((fileSystemOptions || {}).existsResult),
152+
exists: () => (fileSystemOptions || {}).existsResult,
149153
extractZip: () => Promise.resolve(),
150154
readDirectory: () => Promise.resolve([])
151155
};
@@ -271,7 +275,9 @@ describe("SysInfo unit tests", () => {
271275
it("on Windows", async () => {
272276
const originalProgramFiles = process.env[PROGRAM_FILES];
273277
process.env[PROGRAM_FILES] = PROGRAM_FILES_ENV_PATH;
274-
sysInfo = mockSysInfo(childProcessResult, { isWindows: true, isDarwin: false, dotNetVersion });
278+
process.env[PROGRAM_FILES_X86] = PROGRAM_FILEX_X86_ENV_PATH;
279+
process.env[LOCAL_APP_DATA] = LOCAL_APP_DATA_ENV_PATH;
280+
sysInfo = mockSysInfo(childProcessResult, { isWindows: true, isDarwin: false, dotNetVersion }, { existsResult: true });
275281
const result = await sysInfo.getSysInfo();
276282
process.env[PROGRAM_FILES] = originalProgramFiles;
277283
assertCommonValues(result);
@@ -517,7 +523,7 @@ ${expectedCliVersion}`;
517523
assert.deepEqual(result.itunesInstalled, undefined);
518524
assert.deepEqual(result.cocoaPodsVer, "0.38.2");
519525
assert.deepEqual(result.xcodeprojLocation, null);
520-
assert.deepEqual(result.isCocoaPodsWorkingCorrectly, undefined);
526+
assert.deepEqual(result.isCocoaPodsWorkingCorrectly, true);
521527
assert.deepEqual(result.xcprojInfo, undefined);
522528
assert.deepEqual(result.isCocoaPodsUpdateRequired, false);
523529
assert.deepEqual(result.pythonInfo, {isInstalled: false, isSixPackageInstalled: false, installationErrorMessage: "Cannot read property 'shouldThrowError' of undefined"});
@@ -538,7 +544,7 @@ ${expectedCliVersion}`;
538544
assert.deepEqual(result.isAndroidSdkConfiguredCorrectly, undefined);
539545
});
540546
it("Android platform is specified", async () => {
541-
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion });
547+
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion }, { existsResult: true });
542548
const result = await sysInfo.getSysInfo({platform: "Android"});
543549

544550
assertCommonSysInfo(result);
@@ -552,7 +558,6 @@ ${expectedCliVersion}`;
552558
assert.deepEqual(result.xcprojInfo, undefined);
553559
assert.deepEqual(result.isCocoaPodsUpdateRequired, undefined);
554560
assert.deepEqual(result.pythonInfo, undefined);
555-
556561
});
557562
it("no platform is specified", async() => {
558563
sysInfo = mockSysInfo(childProcessResult, { isWindows: false, isDarwin: true, dotNetVersion });

0 commit comments

Comments
 (0)