Skip to content

Commit

Permalink
feat(completions): Add hooks for volta
Browse files Browse the repository at this point in the history
  • Loading branch information
abgox committed Aug 5, 2024
1 parent 82c1b18 commit 848409b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion completions/volta/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"language": ["en-US", "zh-CN"]
"language": ["en-US", "zh-CN"],
"hooks": true
}
2 changes: 1 addition & 1 deletion completions/volta/guid.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d5ab4c01-bfb7-4476-bb86-8f4644e0129b
8fcc9e1a-22b0-4fe6-b892-b4d70174c795
20 changes: 20 additions & 0 deletions completions/volta/hooks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function handleCompletions([System.Collections.Generic.List[System.Object]]$completions) {
function addCompletion($name, $tip = ' ', $symbol = '') {
$completions.Add(@{
name = $name
symbol = $symbol
tip = $tip
})
}
$voltaBinDir = Split-Path (Get-Command volta).Source -Parent
$toolsDir = "$(Split-Path $voltaBinDir -Parent)\tools\image"
$list = @("node", "npm", "pnpm", "yarn")

foreach ($l in $list) {
$versionList = Get-ChildItem "$toolsDir\$l" -Directory
foreach ($v in $versionList) {
addCompletion "pin $l@$($v.BaseName)" "pin - $l@$($v.BaseName)"
}
}
return $completions
}
1 change: 1 addition & 0 deletions completions/volta/language/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"root": [
{
"name": "pin",
"symbol": "SpaceTab",
"tip": [
"Pin your project's runtime or package manager\n",
"E: pin node@lts"
Expand Down
1 change: 1 addition & 0 deletions completions/volta/language/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"root": [
{
"name": "pin",
"symbol": "SpaceTab",
"tip": ["锁定项目运行时或包管理器\n", "E: pin node@lts"]
},
{
Expand Down

0 comments on commit 848409b

Please sign in to comment.