Skip to content

Commit

Permalink
feat: add windows dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Dec 23, 2018
1 parent 807f772 commit 5493e1d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions cmd/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type LinuxDistribution int
const (
// Unknown is the catch-all distro
Unknown LinuxDistribution = 0
// Ubuntu distribution
Ubuntu LinuxDistribution = 1
)

Expand All @@ -31,7 +32,7 @@ func GetLinuxDistroInfo() *DistroInfo {

lsbRelease := program.FindProgram("lsb_release")
if lsbRelease != nil {
stdout, _, err, _ := lsbRelease.Run("-a")
stdout, _, _, err := lsbRelease.Run("-a")
if err != nil {
return result
}
Expand Down Expand Up @@ -72,7 +73,7 @@ func DpkgInstalled(packageName string) (bool, error) {
if dpkg == nil {
return false, fmt.Errorf("cannot check dependencies: dpkg not found")
}
_, _, _, exitCode := dpkg.Run("-L", packageName)
_, _, exitCode, _ := dpkg.Run("-L", packageName)
result = exitCode == 0
return result, nil
}
2 changes: 2 additions & 0 deletions cmd/prerequisites.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func getRequiredProgramsLinux() *Prerequisites {
// TODO: Test this on Windows
func getRequiredProgramsWindows() *Prerequisites {
result := &Prerequisites{}
result.Add(newPrerequisite("gcc", "Please install gcc from here and try again: http://tdm-gcc.tdragon.net/download. You will need to add the bin directory to your path, EG: C:\\TDM-GCC-64\\bin\\"))
result.Add(newPrerequisite("npm", "Please install node/npm from here and try again: https://nodejs.org/en/download/"))
return result
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ func (p *ProgramHelper) FindProgram(programName string) *Program {
}
}

// GetFullPathToBinary returns the full path the the current binary
func (p *Program) GetFullPathToBinary() (string, error) {
return filepath.Abs(p.Path)
}

// Run will execute the program with the given parameters
// Returns stdout + stderr as strings and an error if one occured
func (p *Program) Run(vars ...string) (stdout, stderr string, err error, exitCode int) {
func (p *Program) Run(vars ...string) (stdout, stderr string, exitCode int, err error) {
command, err := p.GetFullPathToBinary()
if err != nil {
return "", "", err, 1
return "", "", 1, err
}
cmd := exec.Command(command, vars...)
var stdo, stde bytes.Buffer
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ require (
github.com/AlecAivazis/survey v1.7.1
github.com/fatih/color v1.7.0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/leaanthony/spinner v0.5.0
github.com/leaanthony/spinner v0.4.0
github.com/leaanthony/synx v0.0.0-20180923230033-60efbd9984b0 // indirect
github.com/leaanthony/wincursor v0.0.0-20180705115120-056510f32d15 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/leaanthony/spinner v0.4.0 h1:y/7FqQqqObRKYI+33bg9DGhHIY7cQHicm+Vz0Uda0Ik=
github.com/leaanthony/spinner v0.4.0/go.mod h1:2Mmv+8Brcw3NwPT1DdOLmW6+zWpSamDDFFsUvVHo2cc=
github.com/leaanthony/spinner v0.5.0 h1:OJKn+0KP6ilHxwCEOv5Lo0wPM4PgWZWLJTeUprGJK0g=
github.com/leaanthony/spinner v0.5.0/go.mod h1:2Mmv+8Brcw3NwPT1DdOLmW6+zWpSamDDFFsUvVHo2cc=
github.com/leaanthony/synx v0.0.0-20180923230033-60efbd9984b0 h1:1bGojw4YacLY5bqQalojiQ7mSfQbe4WIWCEgPZagowU=
github.com/leaanthony/synx v0.0.0-20180923230033-60efbd9984b0/go.mod h1:Iz7eybeeG8bdq640iR+CwYb8p+9EOsgMWghkSRyZcqs=
github.com/leaanthony/wincursor v0.0.0-20180705115120-056510f32d15 h1:166LIty6ldcyOc7tbgfu5smsGATvEo0JZV6bnbzyEc4=
github.com/leaanthony/wincursor v0.0.0-20180705115120-056510f32d15/go.mod h1:7TVwwrzSH/2Y9gLOGH+VhA+bZhoWXBRgbGNTMk+yimE=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
Expand Down

0 comments on commit 5493e1d

Please sign in to comment.