Skip to content

Commit

Permalink
Add install.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
tzmfreedom committed May 3, 2017
1 parent c542419 commit 6a6f23b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 6a6f23b

Please sign in to comment.