// DefaultOptions returns the default Options of the Plugin func DefaultOptions() Options { root, err := os.Getwd() if err != nil { panic("Typescript Plugin: Cannot get the Current Working Directory !!! [os.getwd()]") } opt := Options{Dir: root + utils.PathSeparator, Ignore: nodeModules, Tsconfig: DefaultTsconfig()} opt.Bin = npm.Abs("typescript/lib/tsc.js") return opt }
// start starts the job func (e *Plugin) start() { if e.config.Username == "" || e.config.Password == "" { e.logger.Println("Error before running alm-tools. You have to set username & password for security reasons, otherwise this plugin won't run.") return } if !npm.Exists("alm/bin/alm") { e.logger.Println("Installing alm-tools, please wait...") res := npm.Install("alm") if res.Error != nil { e.logger.Print(res.Error.Error()) return } e.logger.Print(res.Message) } cmd := utils.CommandBuilder("node", npm.Abs("alm/src/server.js")) cmd.AppendArguments("-a", e.config.Username+":"+e.config.Password, "-h", e.config.Host, "-t", strconv.Itoa(e.config.Port), "-d", e.config.WorkingDir[0:len(e.config.WorkingDir)-1]) // for auto-start in the browser: cmd.AppendArguments("-o") if e.keyfile != "" && e.certfile != "" { cmd.AppendArguments("--httpskey", e.keyfile, "--httpscert", e.certfile) } //For debug only: //cmd.Stdout = os.Stdout //cmd.Stderr = os.Stderr //os.Stdin = os.Stdin err := cmd.Start() if err != nil { e.logger.Println("Error while running alm-tools. Trace: " + err.Error()) return } //we lose the internal error handling but ok... e.logger.Printf("Editor is running at %s:%d | %s", e.config.Host, e.config.Port, e.config.WorkingDir) }