Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion checks/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"strings"
"time"

Expand All @@ -22,7 +23,14 @@ func runCLICommand(command api.CLIStepCLICommand, variables map[string]string) (
finalCommand := InterpolateVariables(command.Command, variables)
result.FinalCommand = finalCommand

cmd := exec.Command("sh", "-c", finalCommand)
var cmd *exec.Cmd

if runtime.GOOS == "windows" {
cmd = exec.Command("powershell", "-Command", finalCommand)
} else {
cmd = exec.Command("sh", "-c", finalCommand)
}

cmd.Env = append(os.Environ(), "LANG=en_US.UTF-8")
b, err := cmd.CombinedOutput()
if ee, ok := err.(*exec.ExitError); ok {
Expand Down
5 changes: 3 additions & 2 deletions client/lessons.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const BaseURLOverrideRequired = "override"

type CLIData struct {
// ContainsCompleteDir bool
BaseURLDefault string
Steps []CLIStep
BaseURLDefault string
Steps []CLIStep
AllowedOperatingSystems []string
}

type CLIStep struct {
Expand Down
13 changes: 13 additions & 0 deletions cmd/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"errors"
"fmt"
"runtime"

"github.com/bootdotdev/bootdev/checks"
api "github.com/bootdotdev/bootdev/client"
Expand Down Expand Up @@ -43,6 +44,18 @@ func submissionHandler(cmd *cobra.Command, args []string) error {
}

data := lesson.Lesson.LessonDataCLI.CLIData

isAllowedOS := false
for _, system := range data.AllowedOperatingSystems {
if system == runtime.GOOS {
isAllowedOS = true
}
}

if !isAllowedOS {
return fmt.Errorf("lesson is not supported for your operating system: \"%s\". Try again with one of the following: %v", runtime.GOOS, data.AllowedOperatingSystems)
}

overrideBaseURL := viper.GetString("override_base_url")
if overrideBaseURL != "" {
fmt.Printf("Using overridden base_url: %v\n", overrideBaseURL)
Expand Down
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build darwin || linux

package main

import (
Expand All @@ -15,7 +13,7 @@ import (
var version string

func main() {
err := cmd.Execute(strings.Trim(version, "\n"))
err := cmd.Execute(strings.TrimSpace(version))
if err != nil {
os.Exit(1)
}
Expand Down
7 changes: 0 additions & 7 deletions main_windows.go

This file was deleted.

2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.20.3
v1.20.4