github储存库_从Github存储库安装Powershell模块

github储存库

The latest years Powershell started expansion to other platforms and now works on Windows, Linux, and MacOS (I even managed to start it on raspberry Pi Debian distro).

最近几年,Powershell开始扩展到其他平台,现在可以在Windows,Linux和MacOS上运行(我什至设法在树莓派Debian发行版上启动它)。

And nowadays the main way for installing modules is PowerShell Gallery but in some situations, it still convenient to install modules directly from the source (the main reason — the main PowerShell modules repo configured to MyGet or NugetServer).

如今,安装模块的主要方法是PowerShell Gallery,但在某些情况下,直接从源代码安装模块仍然很方便(主要原因-将主要的PowerShell模块存储库配置为MyGet或NugetServer)。

And it can be painful to install Module from GitHub — you should download archive, find modules folder extract archive content and then copy module folder to the Powershell Profile directory.

从GitHub安装Module可能很痛苦-您应该下载档案,找到modules文件夹提取档案内容,然后将Module文件夹复制到Powershell Profile目录。

Moreover — people like me don't want to create a separate repository for each module (yes, I like the Release-Flow approach) so download and extract only the modules you are like -it even more difficult.

而且-像我这样的人不想为每个模块创建单独的存储库(是的,我喜欢Release-Flow方法),因此仅下载和提取您喜欢的模块-更加困难。

Of course, there are several scripts ower the internet that aim to download and install the PowerShell module from GitHub but I didn't find any allowing to install Module from any folder of the Repository in Github. It is the way how to appear the project `InstallFromGithub`.

当然,互联网上有几个脚本旨在从GitHub下载并安装PowerShell模块,但我找不到任何允许从Github中存储库的任何文件夹安装Module的脚本。 这是显示项目` InstallFromGithub`的方式

The first time I have used this installer only for my Powershell Modules, but then decided to separate it to allow use in any script of any repository.

我第一次仅将此安装程序用于我的Powershell模块,但随后决定将其分开以允许在任何存储库的任何脚本中使用。

Meet the 'install.ps1' script!

符合“ install.ps1”脚本!

For example, let's try to install Bookmarks module from PowershellScripts repo directly from the GitHub account:

例如,让我们尝试直接从GitHub帐户从PowershellScripts存储库安装Bookmarks模块:

We just need to set parameters

我们只需要设置参数

$user="stadub";
$repo="PowershellScripts"
$module="Bookmarks"

also, you can leave the $module variable as blank to indicate the module placed in the root folder

另外,您可以将$ module变量保留为空白,以指示将模块放置在根文件夹中

So installation string will be:

因此安装字符串将是:

iex ('$module="Bookmarks";$user="stadub";$repo="PowershellScripts"'+(new-object net.webclient).DownloadString('https://raw.githubusercontent.com/PsModuleInstall/InstallFromGithub/master/install.ps1'))

Now to check if it works lets import GHiPS and EventLogDrive

现在要检查它是否起作用,让我们导入GHiPS和EventLogDrive

Import-Module Bookmarks

Simple, right?!

简单吧?

Under the hood, there is a downloader script that works on any platform with progress and installation check so you won't rewrite your existing module.

在后台,有一个下载器脚本可以在任何带有进度和安装检查的平台上运行,因此您不会重写现有模块。

As I mentioned before the script separated from other modules and to allows any person to use the unified installer.

如前所述,该脚本与其他模块分开,并允许任何人使用统一安装程序。

And if you have any suggestions or bug report you are welcome to create an issue in the repo.

并且,如果您有任何建议或错误报告,也欢迎在存储库中创建问题

Best wishes and happy coding,

衷心祝福,祝您编程愉快!

Dima Stadub

迪玛·斯塔杜布(Dima Stadub)

翻译自: https://habr.com/en/post/476914/

github储存库

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值