-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.ps1
57 lines (48 loc) · 1.52 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$storageDir = split-path -parent $MyInvocation.MyCommand.Definition
$webclient = New-Object System.Net.WebClient
$url = "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-windows.zip"
$file = "$storageDir\phantomjs.zip"
$webclient.DownloadFile($url,$file)
$url = "https://github.com/n1k0/casperjs/zipball/1.1-beta3"
$file = "$storageDir\casperjs.zip"
$webclient.DownloadFile($url,$file)
$shell = new-object -com shell.application
$zip = $shell.NameSpace("$storageDir\phantomjs.zip")
foreach($item in $zip.items())
{
$shell.Namespace("$storageDir").copyhere($item)
}
$zip = $shell.NameSpace("$storageDir\casperjs.zip")
foreach($item in $zip.items())
{
$shell.Namespace("$storageDir").copyhere($item)
}
$Paths = Get-ChildItem -Path $storageDir -Recurse
$casperPath = ""
foreach ($item in $Paths)
{
if ($item.FullName.EndsWith("\bin\casperjs"))
{
$casperPath = $item.FullName
}
}
$phantomPath = ""
foreach ($item in $Paths)
{
if ($item.FullName.EndsWith("\phantomjs.exe"))
{
$phantomPath = $item.FullName
}
}
echo $casperPath
$casperPathArray = $casperPath -split '\\'
$cLen = $casperPathArray.length - 2
$casperPath = $casperPathArray[0..$cLen] -join '\'
echo $phantomPath
$phantomPathArray = $phantomPath -split '\\'
$pLen = $phantomPathArray.length - 2
$phantomPath = $phantomPathArray[0..$pLen] -join '\'
Remove-Item "$storageDir\phantomjs.zip"
Remove-Item "$storageDir\casperjs.zip"
$env:Path += ";$phantomPath;$casperPath"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)