public override async Task<bool> Install ()
		{
			var runner = new BrewRunner (Context.Instance);
			if (!String.IsNullOrEmpty (HomebrewTapName)) {
				if (!await runner.Tap (HomebrewTapName))
					return false;
			}

			bool install = !InstalledButWrongVersion;
			bool success;
			if (multipleVersionsPickle) {
				Log.InfoLine ($"{Name} has multiple versions installed, let's get out of this pickle");
				// 1. unpin
				success = await runner.UnPin (Name);
				
				// 2. unlink
				success = await runner.Unlink (Name);
				
				// 3. uninstall --ignore-dependencies
				success = await runner.Uninstall (Name, ignoreDependencies: true, force: true);
				install = true;
			}

			string installName = HomebrewFormulaUrl != null ? HomebrewFormulaUrl.ToString () : Name;
			if (!install) {
				success = await runner.Upgrade (installName);
			} else
				success = await runner.Install (installName);

			if (!success || !Pin)
				return success;

			return await runner.Pin (Name);
		}
        protected override async Task AfterDetect(bool installed)
        {
            if (!installed)
            {
                return;
            }

            var runner = new BrewRunner(Context.Instance);

            if (InstalledButWrongVersion)
            {
                Log.DebugLine($"Unpinning {Name} as wrong version installed (may show warnings if package isn't pinned)");
                await runner.UnPin(Name);

                return;
            }

            if (!Pin)
            {
                return;
            }

            Log.DebugLine($"Pinning {Name} to version {CurrentVersion}");
            await runner.Pin(Name);
        }
Esempio n. 3
0
        protected override async Task AfterDetect(bool installed)
        {
            if (!installed)
            {
                return;
            }

            var runner = new BrewRunner(Context.Instance);

            if (InstalledButWrongVersion)
            {
                Log.DebugLine($"Unpinning {Name} as wrong version installed (may show warnings if package isn't pinned)");
                await runner.UnPin(Name);

                return;
            }

            // It may happen that the package is installed but not linked to the prefix that's in the user's PATH.
            // Detecting whether the package is linked would require requesting and parsing JSON for all the packages which
            // would be more trouble than it's worth. Let's just link the package
            await runner.Link(Name, echoOutput : false, echoError : false);

            if (!Pin)
            {
                return;
            }

            Log.DebugLine($"Pinning {Name} to version {CurrentVersion}");
            await runner.Pin(Name);
        }