diff --git a/completions/volta/config.json b/completions/volta/config.json index 70ec616..68c63ed 100644 --- a/completions/volta/config.json +++ b/completions/volta/config.json @@ -1,3 +1,4 @@ { - "language": ["en-US", "zh-CN"] + "language": ["en-US", "zh-CN"], + "hooks": true } diff --git a/completions/volta/guid.txt b/completions/volta/guid.txt index 972f958..73014bc 100644 --- a/completions/volta/guid.txt +++ b/completions/volta/guid.txt @@ -1 +1 @@ -d5ab4c01-bfb7-4476-bb86-8f4644e0129b +8fcc9e1a-22b0-4fe6-b892-b4d70174c795 diff --git a/completions/volta/hooks.ps1 b/completions/volta/hooks.ps1 new file mode 100644 index 0000000..6b8c9ae --- /dev/null +++ b/completions/volta/hooks.ps1 @@ -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 +} diff --git a/completions/volta/language/en-US.json b/completions/volta/language/en-US.json index 28a9b82..ebe6aa1 100644 --- a/completions/volta/language/en-US.json +++ b/completions/volta/language/en-US.json @@ -2,6 +2,7 @@ "root": [ { "name": "pin", + "symbol": "SpaceTab", "tip": [ "Pin your project's runtime or package manager\n", "E: pin node@lts" diff --git a/completions/volta/language/zh-CN.json b/completions/volta/language/zh-CN.json index 40feea5..c5c0d29 100644 --- a/completions/volta/language/zh-CN.json +++ b/completions/volta/language/zh-CN.json @@ -2,6 +2,7 @@ "root": [ { "name": "pin", + "symbol": "SpaceTab", "tip": ["锁定项目运行时或包管理器\n", "E: pin node@lts"] }, {