예제 #1
0
    def _locate_nuget_path(self, nuget_path):
        """
        Locates NuGet executable path from user input or NuGet facade.
        @:raises click.UsageError
        """
        # If NuGet path is provided, check if it's valid
        if nuget_path:
            if not NuGetRunner.valid_nuget_executable(nuget_path):
                raise click.UsageError(nuget_path + " is not a valid NuGet executable.")
            else:
                return nuget_path

        # NuGet is not provided, locate
        nuget_path = NuGetRunner.locate_nuget()
        if nuget_path:
            return nuget_path

        # Failed to locate
        if not self.quiet:
            if sys.platform == 'win32':
                click.secho('You can install NuGet from the official website: https://www.nuget.org/downloads')
                click.secho('You might need to add NuGet installation folder to your PATH variable.')
            elif sys.platform == 'darwin':
                click.secho('You can install NuGet using Homebrew ("brew install nuget") or '
                            'download from the official website')
                click.secho('You might need to add NuGet installation folder to your PATH variable.')
        raise click.UsageError('Failed to locate NuGet executable.')
예제 #2
0
 def test_nuget_runner_locate_nuget(self, mock_call):
     """Test NuGetRunner.locate_nuget """
     mock_call.return_value = 0
     assert NuGetRunner.locate_nuget() == "nuget"