Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolateyGH-588) Extensions enhancements
  • Loading branch information
ferventcoder committed Jan 27, 2016
2 parents 1ae8ede + 05ec6a7 commit 05eb98b
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,11 @@ private void handle_extension_packages(ChocolateyConfiguration config, PackageRe
if (packageResult == null) return;
_fileSystem.create_directory_if_not_exists(ApplicationParameters.ExtensionsLocation);

if (!packageResult.Name.to_lower().EndsWith(".extension")) return;
if (!packageResult.Name.to_lower().EndsWith(".extension") && !packageResult.Name.to_lower().EndsWith(".extensions")) return;

var extensionsFolderName = packageResult.Name.to_lower().Replace(".extensions", string.Empty).Replace(".extension", string.Empty);
var pkgExtensions = _fileSystem.combine_paths(ApplicationParameters.ExtensionsLocation, extensionsFolderName);

var pkgExtensions = _fileSystem.combine_paths(ApplicationParameters.ExtensionsLocation, packageResult.Name);
FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.delete_directory_if_exists(pkgExtensions, recursive: true),
"Attempted to remove '{0}' but had an error".format_with(pkgExtensions));
Expand All @@ -736,11 +738,22 @@ private void handle_extension_packages(ChocolateyConfiguration config, PackageRe
if (packageResult.InstallLocation == null) return;

_fileSystem.create_directory_if_not_exists(pkgExtensions);

var extensionsFolder = _fileSystem.combine_paths(packageResult.InstallLocation, "extensions");

var extensionFolderToCopy = _fileSystem.directory_exists(extensionsFolder) ? extensionsFolder : packageResult.InstallLocation;

FaultTolerance.try_catch_with_logging_exception(
() => _fileSystem.copy_directory(packageResult.InstallLocation, pkgExtensions, overwriteExisting: true),
"Attempted to copy{0} '{1}'{0} to '{2}'{0} but had an error".format_with(Environment.NewLine, packageResult.InstallLocation, pkgExtensions));
() => _fileSystem.copy_directory(extensionFolderToCopy, pkgExtensions, overwriteExisting: true),
"Attempted to copy{0} '{1}'{0} to '{2}'{0} but had an error".format_with(Environment.NewLine, extensionFolderToCopy, pkgExtensions));

string logMessage = "Installed/updated extension for {0}. You will be able to use it on next run.".format_with(packageResult.Name);
string logMessage = " Installed/updated {0} extensions.".format_with(extensionsFolderName);
this.Log().Warn(logMessage);
packageResult.Messages.Add(new ResultMessage(ResultType.Note, logMessage));
}
else
{
string logMessage = " Uninstalled {0} extensions.".format_with(extensionsFolderName);
this.Log().Warn(logMessage);
packageResult.Messages.Add(new ResultMessage(ResultType.Note, logMessage));
}
Expand Down

0 comments on commit 05eb98b

Please sign in to comment.