1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-22 03:15:58 +00:00

formatting

Former-commit-id: 037081db5d6d4434e873ca8b75334ee43e046b6a
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-08-17 10:06:20 +03:00
parent 00967408dc
commit 07046ab978
112 changed files with 477 additions and 517 deletions

View File

@@ -105,8 +105,8 @@ func (tsconfig *Tsconfig) CompilerArgs() []string {
var valueField string
// only if it's string or int we need to put that
if valueFieldG.Kind() == reflect.String {
//if valueFieldG.String() != "" {
//valueField = strconv.QuoteToASCII(valueFieldG.String())
// if valueFieldG.String() != "" {
// valueField = strconv.QuoteToASCII(valueFieldG.String())
// }
valueField = valueFieldG.String()
} else if valueFieldG.Kind() == reflect.Int {
@@ -174,7 +174,6 @@ func DefaultTsconfig() Tsconfig {
},
Exclude: []string{"node_modules"},
}
}
// DefaultConfig returns the default Options of the Typescript adaptor

View File

@@ -52,10 +52,8 @@ type (
}
)
var (
// NoOpLogger can be used as the logger argument, it prints nothing.
NoOpLogger = func(string, ...interface{}) {}
)
// NoOpLogger can be used as the logger argument, it prints nothing.
var NoOpLogger = func(string, ...interface{}) {}
// New creates and returns an Editor Plugin instance
func New(cfg ...Config) *Editor {

View File

@@ -7,10 +7,8 @@ import (
"strings"
)
var (
// PathSeparator is the string of os.PathSeparator
PathSeparator = string(os.PathSeparator)
)
// PathSeparator is the string of os.PathSeparator
var PathSeparator = string(os.PathSeparator)
type (
// Cmd is a custom struch which 'implements' the *exec.Cmd
@@ -24,7 +22,7 @@ type (
//
// In typical use, both Path and args are set by calling Command.
func (cmd *Cmd) Arguments(args ...string) *Cmd {
cmd.Cmd.Args = append(cmd.Cmd.Args[0:1], args...) //we need the first argument which is the command
cmd.Cmd.Args = append(cmd.Cmd.Args[0:1], args...) // we need the first argument which is the command
return cmd
}
@@ -36,7 +34,7 @@ func (cmd *Cmd) AppendArguments(args ...string) *Cmd {
// ResetArguments resets the arguments
func (cmd *Cmd) ResetArguments() *Cmd {
cmd.Args = cmd.Args[0:1] //keep only the first because is the command
cmd.Args = cmd.Args[0:1] // keep only the first because is the command
return cmd
}
@@ -58,12 +56,12 @@ func CommandBuilder(command string, args ...string) *Cmd {
return &Cmd{Cmd: exec.Command(command, args...)}
}
//the below is just for exec.Command:
// the below is just for exec.Command:
// Command executes a command in shell and returns it's output, it's block version
func Command(command string, a ...string) (output string, err error) {
var out []byte
//if no args given, try to get them from the command
// if no args given, try to get them from the command
if len(a) == 0 {
commandArgs := strings.Split(command, " ")
for _, commandArg := range commandArgs {

View File

@@ -7,11 +7,9 @@ import (
"time"
)
var (
// nodeModulesPath is the path of the root npm modules
// Ex: C:\\Users\\iris\\AppData\\Roaming\\npm\\node_modules
nodeModulesPath string
)
// nodeModulesPath is the path of the root npm modules
// Ex: C:\\Users\\iris\\AppData\\Roaming\\npm\\node_modules
var nodeModulesPath string
type (
// NodeModuleResult holds Message and Error, if error != nil then the npm command has failed
@@ -26,7 +24,7 @@ type (
// NodeModulesPath sets the root directory for the node_modules and returns that
func NodeModulesPath() string {
if nodeModulesPath == "" {
nodeModulesPath = MustCommand("npm", "root", "-g") //here it ends with \n we have to remove it
nodeModulesPath = MustCommand("npm", "root", "-g") // here it ends with \n we have to remove it
nodeModulesPath = nodeModulesPath[0 : len(nodeModulesPath)-1]
}
return nodeModulesPath
@@ -64,11 +62,10 @@ func NodeModuleInstall(moduleName string) NodeModuleResult {
case v := <-finish:
{
if v {
print("\010\010\010") //remove the loading chars
print("\010\010\010") // remove the loading chars
close(finish)
return
}
}
default:
print("\010\010-")
@@ -84,7 +81,6 @@ func NodeModuleInstall(moduleName string) NodeModuleResult {
print("|")
}
}
}()
out, err := Command("npm", "install", moduleName, "-g")
finish <- true
@@ -93,7 +89,6 @@ func NodeModuleInstall(moduleName string) NodeModuleResult {
}
return success("\n%s installed %s", moduleName, out)
}
// NodeModuleUnistall removes a module
@@ -103,7 +98,6 @@ func NodeModuleUnistall(moduleName string) NodeModuleResult {
return fail("Error unstalling module %s. Trace: %s", moduleName, err.Error())
}
return success("\n %s unistalled %s", moduleName, out)
}
// NodeModuleAbs returns the absolute path of the global node_modules directory + relative
@@ -113,8 +107,8 @@ func NodeModuleAbs(relativePath string) string {
// NodeModuleExists returns true if a module exists
// here we have two options
//1 . search by command something like npm -ls -g --depth=x
//2. search on files, we choose the second
// 1 . search by command something like npm -ls -g --depth=x
// 2. search on files, we choose the second
func NodeModuleExists(execPath string) bool {
if !filepath.IsAbs(execPath) {
execPath = NodeModuleAbs(execPath)

View File

@@ -32,10 +32,8 @@ func New(cfg ...Config) *Typescript {
return &Typescript{Config: &c}
}
var (
// NoOpLogger can be used as the logger argument, it prints nothing.
NoOpLogger = func(string, ...interface{}) {}
)
// NoOpLogger can be used as the logger argument, it prints nothing.
var NoOpLogger = func(string, ...interface{}) {}
// Run starts the typescript filewatcher watcher and the typescript compiler.
func (t *Typescript) Run(logger func(format string, a ...interface{})) {
@@ -68,7 +66,7 @@ func (t *Typescript) Run(logger func(format string, a ...interface{})) {
func (t *Typescript) start() {
if t.hasTypescriptFiles() {
//Can't check if permission denied returns always exists = true....
// Can't check if permission denied returns always exists = true....
if !npm.NodeModuleExists(t.Config.Bin) {
t.log("installing typescript, please wait...")
@@ -85,7 +83,7 @@ func (t *Typescript) start() {
watchedProjects := 0
// typescript project (.tsconfig) found
for _, project := range projects {
cmd := npm.CommandBuilder("node", t.Config.Bin, "-p", project[0:strings.LastIndex(project, npm.PathSeparator)]) //remove the /tsconfig.json)
cmd := npm.CommandBuilder("node", t.Config.Bin, "-p", project[0:strings.LastIndex(project, npm.PathSeparator)]) // remove the /tsconfig.json)
projectConfig, perr := FromFile(project)
if perr != nil {
t.log("error while trying to read tsconfig: %s", perr.Error())
@@ -114,7 +112,7 @@ func (t *Typescript) start() {
}
return
}
//search for standalone typescript (.ts) files and compile them
// search for standalone typescript (.ts) files and compile them
files := t.getTypescriptFiles()
if len(files) > 0 {
/* watchedFiles := 0
@@ -144,12 +142,11 @@ func (t *Typescript) start() {
go func() {
compilerMsgB, _ := cmd.Output()
compilerMsg := string(compilerMsgB)
cmd.Args = cmd.Args[0 : len(cmd.Args)-1] //remove the last, which is the file
cmd.Args = cmd.Args[0 : len(cmd.Args)-1] // remove the last, which is the file
if strings.Contains(compilerMsg, "error") {
t.log(compilerMsg)
}
}()
}
@@ -211,7 +208,7 @@ func (t *Typescript) getTypescriptProjects() []string {
ignoreFolders := t.getIgnoreFolders()
root := t.Config.Dir
//t.logger.Printf("\nSearching for typescript projects in %s", root)
// t.logger.Printf("\nSearching for typescript projects in %s", root)
// ignore error
filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
@@ -225,7 +222,7 @@ func (t *Typescript) getTypescriptProjects() []string {
}
if strings.HasSuffix(path, npm.PathSeparator+"tsconfig.json") {
//t.logger.Printf("\nTypescript project found in %s", path)
// t.logger.Printf("\nTypescript project found in %s", path)
projects = append(projects, path)
}
@@ -253,7 +250,7 @@ func (t *Typescript) getTypescriptFiles() []string {
}
if strings.HasSuffix(path, ".ts") {
//t.logger.Printf("\nTypescript file found in %s", path)
// t.logger.Printf("\nTypescript file found in %s", path)
files = append(files, path)
}