diff --git a/hooks/available.lua b/hooks/available.lua index 0683bb3..3f2f3a5 100644 --- a/hooks/available.lua +++ b/hooks/available.lua @@ -1,4 +1,5 @@ local json = require("json") +local http = require("http") local nodejsUtils = require("nodejs_utils") --- Return all available versions provided by this plugin diff --git a/hooks/pre_use.lua b/hooks/pre_use.lua index e723328..32b74bf 100644 --- a/hooks/pre_use.lua +++ b/hooks/pre_use.lua @@ -1,25 +1,16 @@ +local nodejsUtils = require("nodejs_utils") --- When user invoke `use` command, this function will be called to get the --- valid version information. --- @param ctx table Context information function PLUGIN:PreUse(ctx) - local runtimeVersion = ctx.runtimeVersion --- user input version local version = ctx.version - --- user current used version - local previousVersion = ctx.previousVersion - --- installed sdks - local sdkInfo = ctx.installedSdks['version'] - local path = sdkInfo.path - local name = sdkInfo.name - local version = sdkInfo.version + local shorthands = nodejsUtils.calculate_shorthand(ctx.installedSdks) - --- working directory - local cwd = ctx.cwd - - --- user input scope - --- could be one of global/project/session - local scope = ctx.scope + if not nodejsUtils.is_semver_simple(version) then + version = shorthands[version] + end --- return the version information return { diff --git a/metadata.lua b/metadata.lua index 5056fc1..1f3b21c 100644 --- a/metadata.lua +++ b/metadata.lua @@ -5,7 +5,7 @@ PLUGIN = {} --- Plugin name PLUGIN.name = "nodejs" --- Plugin version -PLUGIN.version = "0.0.4" +PLUGIN.version = "0.0.5" --- Plugin repository PLUGIN.homepage = "https://github.com/version-fox/vfox-nodejs" --- Plugin license