Skip to content
Snippets Groups Projects
Commit fd9a7f7f authored by Recolic K's avatar Recolic K
Browse files

add a global.json warning utility

parent 10b6d7a0
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ import (
// Some options here. Would be improved in beta release.
const DEDUCT_PKGNAME_FROM_VARNAME = true
const USE_PROJECT_NETVER_INSTEAD_OF_HINTPATH_NETVER = false
const OPENXT_VERSION = "1.4.1-1"
const OPENXT_VERSION = "1.4.1-2"
func print_help_and_exit() {
println("Usage: openxt <subcommand> [options...]")
......
......@@ -4,6 +4,7 @@ import (
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
)
......@@ -40,6 +41,39 @@ func stringReplaceOnceInsensitive(s, old, new string) string {
}
///////////////////////////// utils END
// Send a warning if there's any "global.json" existing in parent path.
// BeginPoint could be a filename, or a directory. However, the leaf entry would be discarded (skipped)!
//
// Example: If beginPoint is `./program/minecraft/hmcl.jar`, then I'll search `./program/minecraft/*`,
// `./program/*`, `./*`, `./../*`, ...
// If beginPoint is `./program/minecraft`, then I'll search `./program/*`, `./*`, `./../*` ...
func warnGlobalJson(beginPoint string) {
// Make it abs path.
if !filepath.IsAbs(beginPoint) {
wd, err := os.Getwd()
if err != nil {
return
}
beginPoint = filepath.Join(wd, beginPoint)
}
// Iterate
currPath := beginPoint
for {
// Go to parent, and exit the loop if we're already on root (`/` or `C:\`).
par := filepath.Dir(currPath)
if par == currPath {
break
}
currPath = par
// Check if global.json exists in this level.
if _, err := os.Stat(filepath.Join(currPath, "global.json")); err == nil {
println("WARNING: Please consider remove " + currPath + string(os.PathSeparator) + "global.json . It may cause problem to your dotnet. ")
}
}
}
// This is a naive tool to convert CoreXT csproj file to dotnet 5 csproj file.
// It should work on 99% well-formatted csproj file.
// |
......@@ -54,7 +88,9 @@ func main() {
content, err := ioutil.ReadFile(fname)
panicErrorIfAny(err, "read file " + fname)
// Good luck for old MacOS! They use single \r as newline.
warnGlobalJson(fname)
// May have problem here for old MacOS! They use single \r as newline.
lines := strings.Split(strings.ReplaceAll(string(content), "\r\n", "\n"), "\n")
resultTxt := ""
removeEndOfTagInNextLine := "" // Empty value indicates no need to remove EOT.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment