Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
70 lines (60 loc) · 1.66 KB
/
Copy pathmain.go
File metadata and controls
70 lines (60 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"log"
"os"
"path/filepath"
"github.com/chaposcripts/lubu/bundler"
"github.com/chaposcripts/lubu/config"
"github.com/chaposcripts/lubu/watcher"
)
const (
VERSION = "1.0.7"
LUBU_COMMAND_OBFUSCATE_START = "---@LUBU:OBFIGNORE"
LUBU_COMMAND_OBFUSCATE_END = "---@LUBU:ENDOBFIGNORE"
LUBU_COMMAND = ""
)
func main() {
log.Println("LuBu Started! Version: " + VERSION)
log.Println("Thanks for using LuBu! GitHub: https://github.com/chaposcripts/lubu/")
if len(os.Args) < 2 {
log.Fatalf("Error, config file not found!")
}
absoluteConfigPath, err := filepath.Abs(os.Args[1])
if err != nil {
log.Fatalf("pizda")
}
basePath, _ := filepath.Split(absoluteConfigPath)
cfgPath := absoluteConfigPath
if !filepath.IsAbs(cfgPath) {
cfgPath, _ = filepath.Abs(cfgPath)
}
// Read config
cfg, err := config.Read(cfgPath)
if err != nil {
log.Fatalf("Error reading config: %v", err)
}
if cfg.Main == "" {
log.Fatalf("Error, main file is empty!")
}
if cfg.Out == "" {
log.Fatalf("Error, output file is empty!")
}
// Validate output file path
if !filepath.IsAbs(cfg.Out) {
cfg.Out = filepath.Join(basePath, cfg.Out)
}
// Print used paths
log.Println("Base Path:", basePath)
log.Println("Config Path:", cfgPath)
log.Println("Output Path:", cfg.Out)
if cfg.PrepareForObfuscation {
log.Println("Prepare for obfuscation is ENABLED!")
}
bundler.Bundle(basePath, cfg)
if cfg.WatcherDelay > 0 {
log.Println("Watcher started! Waiting for files change...")
watcher.StartWatcher(basePath, cfg, absoluteConfigPath)
} else {
log.Println("Watcher disabled. \"watcher_delay\" must be more than zero!")
}
}