Skip to content

Make Update-module behave more like nuget update/choco update  #77

Open
@darksidemilk

Description

@darksidemilk

Expected Behavior

Example from related tool

in chocolatey and I believe nuget as well you can install a package that isn't already installed or update one that is with choco update packagename or nuget update packagename this makes it so one command can be universal for installing or upgrading a package making dependency handling and general install/maintenance an easier one line task.

Application

If Update-Module would call install-module if it finds the module in a trusted repository when it isn't already installed, it could make for a much smoother experience.

Additional automation for reloading

Update-Module should also have the ability to 'reload' the module that was updated.
So as soon as the update or new install is done it removes the module from the session if it already exists and then imports the new version unless it was otherwise specified to not import

Current Behavior

Installations

If you try to run update-module on a module that isn't installed it just says that one isn't installed

Reloading

Currently to get the new version of a module in your powershell session properly you need to

  1. update the module
  2. remove the module
    3 import the module
    If you try to just import the module after updating, it will import both version side by side.
    While I realize there are times when side by side module versions may be needed, other times this creates collisions and confusion as to which version of any given function will end up being used.

Possible Solution

For adding installing, I imagine a try/catch block for catching when modules aren't already installed and trying to install would do the trick for most cases.

perhaps reloading could be implemented via switch parameter to turn this off if it became default behavior or on to do this on demand
i.e there be a -Import or -reload or alternatively and preferably a -noreload or -noimport switch.
There could also just be a separate function for this functionality such as sync-module or some other verb that isn't there yet.

Context

It becomes a bit tedious to have to run 3 different commands to get an updated module into a session or script. As well keeping modules up to date and getting new ones installed gets difficult. With chocolatey packages I only ever use the cup command because it is so much simpler to install and update with one command.

Your Environment

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.228
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.228
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions