Skip to content

Commit

Permalink
(chocolatey#1185) Add switch to skip hooks
Browse files Browse the repository at this point in the history
This adds a switch to the install, upgrade and uninstall commands to
skip running hook scripts. It adds a configuration option
SkipHookScripts.
  • Loading branch information
TheCakeIsNaOH committed Mar 21, 2022
1 parent 32824b4 commit a956d8e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
.Add("skip-hooks|skiphooks|sh",
"Skip hooks - Do not run hook scripts",
option => configuration.SkipHookScripts = option != null
)
;

//todo: #770 package name can be a url / installertype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.ExitOnRebootDetected = false;
}
})
.Add("skip-hooks|skiphooks|sh",
"Skip hooks - Do not run hook scripts",
option => configuration.SkipHookScripts = option != null
)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
.Add("skip-hooks|skiphooks|sh",
"Skip hooks - Do not run hook scripts",
option => configuration.SkipHookScripts = option != null
)
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ private void append_output(StringBuilder propertyValues, string append)
public bool AllVersions { get; set; }
public bool SkipPackageInstallProvider { get; set; }
public string OutputDirectory { get; set; }
public bool SkipHookScripts { get; set; }

// install/update
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ private string get_script_for_action(PackageResult packageResult, CommandNameTyp
private IEnumerable<string> get_hook_scripts(ChocolateyConfiguration configuration, PackageResult packageResult, CommandNameType command, bool isPre)
{
List<string> hookScriptPaths = new List<string>();

// If skipping hook scripts, return an empty list
if (configuration.SkipHookScripts) return hookScriptPaths;

string filenameBase;

if (isPre)
Expand Down

0 comments on commit a956d8e

Please sign in to comment.