-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-node-alias.ps1
68 lines (56 loc) · 1.28 KB
/
docker-node-alias.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
58
59
60
61
62
63
64
65
66
67
# Test if maven is installed locally
function Test-NodeInstall {
try {
node --version | Out-Null
return $true
}
catch {
return $false
}
}
#
function Run-Node {
docker run -it --rm -v "${PWD}:/node" -w /node dsuite/alpine-nodejs:lts sh -c "node $args"
}
#
function Run-Npm {
docker run -it --rm -v "${PWD}:/node" -w /node dsuite/alpine-nodejs:lts sh -c "npm $args"
}
#
function Run-Yarn {
docker run -it --rm -v "${PWD}:/node" -w /node dsuite/alpine-nodejs:lts bash -c "yarn $args"
}
#
function Run-NodeBash {
docker run -it --rm -v "${PWD}:/node" -w /node dsuite/alpine-nodejs:lts bash
}
#
if (test-path alias:node) {
Remove-Item alias:node
}
#
if( (Test-NodeInstall) -eq $true) {
if (test-path alias:nodebash) {
Remove-Item alias:nodebash
}
New-Alias nodebash Run-NodeBash
}
#
if( (Test-NodeInstall) -eq $false) {
if (test-path alias:node) {
Remove-Item alias:node
}
New-Alias node Run-Node
if (test-path alias:npm) {
Remove-Item alias:npm
}
New-Alias npm Run-Npm
if (test-path alias:yarn) {
Remove-Item alias:yarn
}
New-Alias yarn Run-Yarn
if (test-path alias:nodebash) {
Remove-Item alias:nodebash
}
New-Alias nodebash Run-NodeBash
}