-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cff3a43
commit 5c6952b
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package installer | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
// RunInstallScripts executes the installation scripts of a PreparedInstall for | ||
// files that have changed (unless ForceReinstall is enabled, in which case | ||
// *all* scripts will be run). | ||
func RunInstallScripts(install PreparedInstall, config InstallConfig) { | ||
for _, script := range install.InstallScripts { | ||
if !script.ShouldInstall() && !config.ForceReinstall { | ||
continue | ||
} | ||
|
||
if !script.Executable { | ||
continue | ||
} | ||
|
||
command := exec.Command(script.Path) | ||
|
||
// Execute the script in the installed path cotnext | ||
if config.OverrideInstallPath != "" { | ||
command.Dir = config.OverrideInstallPath | ||
} else { | ||
command.Dir = config.SourceConfig.InstallPath | ||
} | ||
|
||
// Setup the environment | ||
command.Env = append( | ||
os.Environ(), | ||
fmt.Sprintf("DOTS_SOURCE=%s", config.SourceConfig.SourcePath), | ||
fmt.Sprintf("DOTS_FORCE_REINSTALL=%t", config.ForceReinstall), | ||
) | ||
|
||
command.Stdout = os.Stdout | ||
command.Stderr = os.Stderr | ||
|
||
command.Run() | ||
} | ||
|
||
} |