mirror of
https://github.com/chenasraf/vstask.git
synced 2026-05-18 01:39:04 +00:00
fix: disable corepack strict mode
This commit is contained in:
@@ -48,6 +48,11 @@ func buildCmd(t tasks.Task, cwd string, env []string) (*exec.Cmd, func(), error)
|
||||
case "npm":
|
||||
npmExe := tasks.ResolvePackageManagerExecutable(cwd, "npm")
|
||||
|
||||
// Disable corepack strict version enforcement so that a
|
||||
// packageManager version mismatch doesn't block execution.
|
||||
// VS Code doesn't go through corepack, so this keeps parity.
|
||||
env = appendEnvIfMissing(env, "COREPACK_ENABLE_STRICT", "0")
|
||||
|
||||
// Support either:
|
||||
// - Command/Script = npm subcommand or script name
|
||||
// - Command empty with first arg being subcommand/script
|
||||
|
||||
@@ -370,6 +370,17 @@ func mergeEnv(base []string, extra map[string]string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// appendEnvIfMissing adds key=value to env only if key is not already set.
|
||||
func appendEnvIfMissing(env []string, key, value string) []string {
|
||||
prefix := key + "="
|
||||
for _, kv := range env {
|
||||
if strings.HasPrefix(kv, prefix) {
|
||||
return env
|
||||
}
|
||||
}
|
||||
return append(env, prefix+value)
|
||||
}
|
||||
|
||||
func defaultShell() (exe string, args []string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "cmd.exe", []string{"/C"}
|
||||
|
||||
Reference in New Issue
Block a user