File tree 4 files changed +30
-8
lines changed
4 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -773,17 +773,27 @@ interface IProjectNameService {
773
773
ensureValidName ( projectName : string , validateOptions ?: { force : boolean } ) : Promise < string > ;
774
774
}
775
775
776
+ /**
777
+ * Describes options that can be passed to xcprojService.verifyXcproj method.
778
+ */
779
+ interface IVerifyXcprojOptions {
780
+ /**
781
+ * Whether to fail with error message or not
782
+ */
783
+ shouldFail : boolean ;
784
+ }
785
+
776
786
/**
777
787
* Designed for getting information about xcproj.
778
788
*/
779
789
interface IXcprojService {
780
790
/**
781
791
* Checks whether the system needs xcproj to execute ios builds successfully.
782
792
* In case the system does need xcproj but does not have it, prints an error message.
783
- * @param {boolean } whether to fail with error message or not
793
+ * @param {IVerifyXcprojOptions } opts whether to fail with error message or not
784
794
* @return {Promise<boolean> } whether an error occurred or not.
785
795
*/
786
- verifyXcproj ( shouldFail : boolean ) : Promise < boolean > ;
796
+ verifyXcproj ( opts : IVerifyXcprojOptions ) : Promise < boolean > ;
787
797
/**
788
798
* Collects information about xcproj.
789
799
* @return {Promise<XcprojInfo> } collected info about xcproj.
@@ -903,4 +913,4 @@ interface IRuntimeGradleVersions {
903
913
904
914
interface INetworkConnectivityValidator {
905
915
validate ( ) : Promise < void > ;
906
- }
916
+ }
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export class CocoaPodsService implements ICocoaPodsService {
34
34
this . $errors . failWithoutHelp ( "CocoaPods or ruby gem 'xcodeproj' is not installed. Run `sudo gem install cocoapods` and try again." ) ;
35
35
}
36
36
37
- await this . $xcprojService . verifyXcproj ( true ) ;
37
+ await this . $xcprojService . verifyXcproj ( { shouldFail : true } ) ;
38
38
39
39
this . $logger . info ( "Installing pods..." ) ;
40
40
const podTool = this . $config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ;
Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ class XcprojService implements IXcprojService {
12
12
private $xcodeSelectService : IXcodeSelectService ) {
13
13
}
14
14
15
- public async verifyXcproj ( shouldFail : boolean ) : Promise < boolean > {
15
+ public async verifyXcproj ( opts : IVerifyXcprojOptions ) : Promise < boolean > {
16
16
const xcprojInfo = await this . getXcprojInfo ( ) ;
17
17
if ( xcprojInfo . shouldUseXcproj && ! xcprojInfo . xcprojAvailable ) {
18
18
const errorMessage = `You are using CocoaPods version ${ xcprojInfo . cocoapodVer } which does not support Xcode ${ xcprojInfo . xcodeVersion . major } .${ xcprojInfo . xcodeVersion . minor } yet.${ EOL } ${ EOL } You can update your cocoapods by running $sudo gem install cocoapods from a terminal.${ EOL } ${ EOL } In order for the NativeScript CLI to be able to work correctly with this setup you need to install xcproj command line tool and add it to your PATH. Xcproj can be installed with homebrew by running $ brew install xcproj from the terminal` ;
19
- if ( shouldFail ) {
19
+ if ( opts . shouldFail ) {
20
20
this . $errors . failWithoutHelp ( errorMessage ) ;
21
21
} else {
22
22
this . $logger . warn ( errorMessage ) ;
Original file line number Diff line number Diff line change 697
697
} ) ;
698
698
699
699
const xcprojService = testInjector . resolve < IXcprojService > ( "xcprojService" ) ;
700
- xcprojService . verifyXcproj = async ( shouldFail : boolean ) : Promise < boolean > => false ;
700
+ xcprojService . verifyXcproj = async ( opts : IVerifyXcprojOptions ) : Promise < boolean > => false ;
701
701
xcprojService . getXcprojInfo = async ( ) : Promise < IXcprojInfo > => ( < any > { } ) ;
702
702
} ) ;
703
703
729
729
it ( "fails with correct error when xcprojService.verifyXcproj throws" , async ( ) => {
730
730
const expectedError = new Error ( "err" ) ;
731
731
const xcprojService = testInjector . resolve < IXcprojService > ( "xcprojService" ) ;
732
- xcprojService . verifyXcproj = async ( shouldFail : boolean ) : Promise < boolean > => {
732
+ xcprojService . verifyXcproj = async ( opts : IVerifyXcprojOptions ) : Promise < boolean > => {
733
733
throw expectedError ;
734
734
} ;
735
735
@@ -756,6 +756,18 @@ end`
756
756
} ) ;
757
757
} ) ;
758
758
759
+ it ( "calls xcprojService.verifyXcproj with correct arguments" , async ( ) => {
760
+ const xcprojService = testInjector . resolve < IXcprojService > ( "xcprojService" ) ;
761
+ let optsPassedToVerifyXcproj : any = null ;
762
+ xcprojService . verifyXcproj = async ( opts : IVerifyXcprojOptions ) : Promise < boolean > => {
763
+ optsPassedToVerifyXcproj = opts ;
764
+ return false ;
765
+ } ;
766
+
767
+ await cocoapodsService . executePodInstall ( projectRoot , xcodeProjPath ) ;
768
+ assert . deepEqual ( optsPassedToVerifyXcproj , { shouldFail : true } ) ;
769
+ } ) ;
770
+
759
771
it ( "calls pod install spawnFromEvent with correct arguments" , async ( ) => {
760
772
const childProcess = testInjector . resolve < IChildProcess > ( "childProcess" ) ;
761
773
let commandCalled = "" ;
You can’t perform that action at this time.
0 commit comments