-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathyarn.ps1
51 lines (47 loc) · 1.36 KB
/
yarn.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
function Show-Help {
Write-Output "Usage: yarn.ps1 [option...]"
Write-Output ""
Write-Output " -h, --help Show this help message"
Write-Output " -v, --version Show script version"
Write-Output " -f, --force Force delete .yarnrc.yml without asking"
Write-Output ""
}
function Show-Version {
Write-Output "1.0"
}
function Delete-Yarnrc {
if (Test-Path .yarnrc.yml) {
if ($ForceDelete) {
Remove-Item .yarnrc.yml
} else {
$response = Read-Host "Do you really want to delete your current .yarnrc.yml? [Y/n]"
if ($response -match "^[Yy]$" -or [string]::IsNullOrEmpty($response)) {
Remove-Item .yarnrc.yml
} else {
exit 1
}
}
}
}
# Parse command line arguments
$ForceDelete = $false
$args | ForEach-Object {
switch ($_) {
"-h" { Show-Help; exit }
"--help" { Show-Help; exit }
"-v" { Show-Version; exit }
"--version" { Show-Version; exit }
"-f" { $ForceDelete = $true }
"--force" { $ForceDelete = $true }
default { Write-Host "Invalid option: $_"; Show-Help; exit 1 }
}
}
# Main script
corepack enable
Delete-Yarnrc
yarn set version stable
yarn set version 4.5.3 --yarn-path
yarn config set nodeLinker node-modules
yarn config set npmScopes.plentymarkets.npmRegistryServer "https://registry.npmjs.org"
yarn config set npmScopes.plentymarkets.npmAlwaysAuth false
yarn