Skip to content

Commit

Permalink
Check that scripts are executable
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jul 15, 2019
1 parent 97039fc commit cff3a43
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions installer/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ func (d FileMode) IsChanged() bool {
// InstallScript represents a single installation script that is mapped to one
// or more dotfiles.
type InstallScript struct {
Path string
RequiredBy []*PreparedDotfile
RequiredBy []*PreparedDotfile
Path string
Executable bool
PrepareError error
}

// ShouldInstall indicates weather the installation script should be executed.
Expand Down Expand Up @@ -231,10 +233,20 @@ func PrepareDotfiles(dotfiles resolver.Dotfiles, config config.SourceConfig) Pre
installScripts := make([]*InstallScript, 0, len(scriptMap))

for path, dotfiles := range scriptMap {
installScripts = append(installScripts, &InstallScript{
script := InstallScript{
RequiredBy: dotfiles,
Path: path,
})
Path: config.SourcePath + separator + path,
}
installScripts = append(installScripts, &script)

scriptInfo, err := os.Stat(script.Path)
if err != nil {
script.PrepareError = err
continue
}

// Verify that the script is executable
script.Executable = scriptInfo.Mode()&0100 == 0100
}

return PreparedInstall{
Expand Down

0 comments on commit cff3a43

Please sign in to comment.