WatchExtensions .
(extName []string, liveUpdate bool)
| 103 | |
| 104 | // WatchExtensions . |
| 105 | func WatchExtensions(extName []string, liveUpdate bool) { |
| 106 | if !isValidForWatching() { |
| 107 | os.Exit(1) |
| 108 | } |
| 109 | |
| 110 | if liveUpdate { |
| 111 | startDebugger() |
| 112 | } |
| 113 | |
| 114 | var extNameList []string |
| 115 | if len(extName) > 0 { |
| 116 | extNameList = extName |
| 117 | } else { |
| 118 | extNameList = featureSection.Key("extensions").Strings("|") |
| 119 | } |
| 120 | |
| 121 | var extPathList []string |
| 122 | |
| 123 | for _, v := range extNameList { |
| 124 | extPath, err := utils.GetExtensionPath(v) |
| 125 | if err != nil { |
| 126 | utils.PrintError(`Extension "` + v + `" not found.`) |
| 127 | continue |
| 128 | } |
| 129 | extPathList = append(extPathList, extPath) |
| 130 | } |
| 131 | |
| 132 | if len(extPathList) == 0 { |
| 133 | utils.PrintError("No extension to watch") |
| 134 | os.Exit(1) |
| 135 | } |
| 136 | |
| 137 | utils.Watch(extPathList, func(filePath string, err error) { |
| 138 | if err != nil { |
| 139 | utils.PrintError(err.Error()) |
| 140 | os.Exit(1) |
| 141 | } |
| 142 | |
| 143 | pushExtensions("", filePath) |
| 144 | |
| 145 | utils.PrintSuccess(utils.PrependTime(`Extension "` + filePath + `" is updated`)) |
| 146 | }, autoReloadFunc) |
| 147 | } |
| 148 | |
| 149 | // WatchCustomApp . |
| 150 | func WatchCustomApp(appName []string, liveUpdate bool) { |
no test coverage detected