mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-17 01:10:36 +03:00
add find_msvs custom command to the nu_msvs module (#881)
I changed `export-env {}` at the beginning to a custom command to avoid having `export-env` run when loading the module because: 1. I couldn't use `nu_msvs activate` because it depends on env vars being set that were hidden with `nu_msvs deactivate` 2. It seems that `export-env` executed at `use`, leaves `$env.FILE_PWD` available in the environment which I think may be a bug. So, putting it in a custom command avoids that.
This commit is contained in:
parent
92f20ff282
commit
ddbebf197d
@ -1,4 +1,5 @@
|
||||
export-env {
|
||||
def --env find_msvs [] {
|
||||
export-env {
|
||||
$env.MSVS_BASE_PATH = $env.Path
|
||||
$env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" })
|
||||
|
||||
@ -58,6 +59,7 @@ export-env {
|
||||
# print $"MSVS_MSDK_ROOT: ($env.MSVS_MSDK_ROOT)"
|
||||
# print $"MSVS_MSDK_VER: ($env.MSVS_MSDK_VER)"
|
||||
# print $"MSVS_INCLUDE_PATH: ($env.MSVS_INCLUDE_PATH)"
|
||||
}
|
||||
}
|
||||
|
||||
export def --env activate [
|
||||
@ -65,6 +67,13 @@ export def --env activate [
|
||||
--target (-t): string = x64, # Target architecture, must be x64 or x86 (case insensitive)
|
||||
--sdk (-s): string = latest # Version of Windows SDK, must be "latest" or a valid version string
|
||||
] {
|
||||
# I changed export-env {} to a custom command to avoid having export-env run when loading the module
|
||||
# because:
|
||||
# 1. I couldn't use activate because it depends on env vars being set that were hidden with deactivate
|
||||
# 2. It seems that export-env executed at `use`, leaves `$env.FILE_PWD` available in the environment
|
||||
# which I think may be a bug. So, putting it in a custom command avoids that.
|
||||
find_msvs
|
||||
|
||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user