From 6a6f23b853358decb3a151b11bc8da26f880177e Mon Sep 17 00:00:00 2001 From: tzmfreedom Date: Wed, 3 May 2017 09:34:25 +0900 Subject: [PATCH] Add install.ps1 --- README.md | 8 ++++++++ install.ps1 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 install.ps1 diff --git a/README.md b/README.md index 9656b01..7f1b638 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,19 @@ $ brew tap tzmfreedom/spm $ brew install spm ``` +You can use docker to use spm command. +```bash +$ docker run tzmfree/spm install {REPO} u {USERNAME] -p {PASSWORD} + +``` + If you want to use latest version, execute following command. ```bash $ go get -u github.com/tzmfreedom/spm ``` +For Windows user, use Linux virtual machine, such as docker or vagrant. + ## Usage ```bash diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..a6d92ed --- /dev/null +++ b/install.ps1 @@ -0,0 +1,30 @@ +$name = "spm" +$bin_name = "spm" +$version = "0.2.1" +$github_user = "tzmfreedom" +If ($Env:PROCESSOR_ARCHITECTURE -match "64") { + $arch = "amd64" +} Else { + $arch = "386" +} +$archive_file = "${name}-${version}-windows-${arch}.zip" +$url = "https://github.com/${github_user}/${name}/releases/download/v${version}/${archive_file}" +$dest_dir = "$Env:APPDATA\${name}" + +wget $url -OutFile "${dest_dir}\tmp.zip" +Expand-Archive -Path "${dest_dir}\tmp.zip" -DestinationPath "${dest_dir}\tmp" -Force +if (!(Test-Path -path "${dest_dir}\bin")) { New-Item "${dest_dir}\bin" -Type Directory } +mv "${dest_dir}\tmp\${bin_name}" "${dest_dir}\bin\${bin_name}.exe" -Force +rm "${dest_dir}\tmp.zip" -Force +rm "${dest_dir}\tmp" -Force -Recurse + +# ensure added to path in registry +$reg_path = [Environment]::GetEnvironmentVariable("PATH", "User") +If ($reg_path -notcontains $dest_dir) { + [Environment]::SetEnvironmentVariable("PATH", $reg_path + ";" + $dest_dir, "User") +} +# ensure added to path for current session +If ($Env:Path -notcontains $dest_dir) { + $Env:Path += ";" + $dest_dir +} +Write-Host "spm installed. Run 'spm help' to try it out."