mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-03 12:14:39 -06:00
Add .bat to script names on Windows
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"runtime"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -147,18 +148,27 @@ func runScript(context *cli.Context, storageName string, phase string) bool {
|
|||||||
|
|
||||||
preferencePath := duplicacy.GetDuplicacyPreferencePath()
|
preferencePath := duplicacy.GetDuplicacyPreferencePath()
|
||||||
scriptDir, _ := filepath.Abs(path.Join(preferencePath, "scripts"))
|
scriptDir, _ := filepath.Abs(path.Join(preferencePath, "scripts"))
|
||||||
scriptName := phase + "-" + context.Command.Name
|
scriptNames := []string { phase + "-" + context.Command.Name,
|
||||||
|
storageName + "-" + phase + "-" + context.Command.Name }
|
||||||
|
|
||||||
script := path.Join(scriptDir, scriptName)
|
script := ""
|
||||||
if _, err := os.Stat(script); err != nil {
|
for _, scriptName := range scriptNames {
|
||||||
scriptName = storageName + "-" + scriptName
|
|
||||||
script = path.Join(scriptDir, scriptName)
|
script = path.Join(scriptDir, scriptName)
|
||||||
if _, err = os.Stat(script); err != nil {
|
if runtime.GOOS == "windows" {
|
||||||
return false
|
script += ".bat"
|
||||||
|
}
|
||||||
|
if _, err := os.Stat(script); err == nil {
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
script = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicacy.LOG_INFO("SCRIPT_RUN", "Running %s script", scriptName)
|
if script == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
duplicacy.LOG_INFO("SCRIPT_RUN", "Running script %s", script)
|
||||||
|
|
||||||
output, err := exec.Command(script, os.Args...).CombinedOutput()
|
output, err := exec.Command(script, os.Args...).CombinedOutput()
|
||||||
for _, line := range strings.Split(string(output), "\n") {
|
for _, line := range strings.Split(string(output), "\n") {
|
||||||
|
|||||||
Reference in New Issue
Block a user