(fileName string)
| 422 | } |
| 423 | |
| 424 | func loadCustomCode(fileName string) (map[string]string, error) { |
| 425 | result := make(map[string]string) |
| 426 | f, err := os.Open(fileName) |
| 427 | if err != nil { |
| 428 | if os.IsNotExist(err) { |
| 429 | return result, nil |
| 430 | } |
| 431 | return result, err |
| 432 | } |
| 433 | defer f.Close() |
| 434 | |
| 435 | bytes, err := io.ReadAll(f) |
| 436 | if err != nil { |
| 437 | return result, err |
| 438 | } |
| 439 | |
| 440 | var currentName string |
| 441 | var currentValue string |
| 442 | lines := strings.Split(string(bytes), "\n") |
| 443 | for _, line := range lines { |
| 444 | trimmedLine := strings.TrimSpace(line) |
| 445 | if strings.HasPrefix(trimmedLine, "//[") && strings.HasSuffix(trimmedLine, ":]") { |
| 446 | currentName = strings.Replace(strings.Replace(trimmedLine, "//[", "", -1), ":]", "", -1) |
| 447 | currentValue = "" |
| 448 | } else if trimmedLine == "//[end]" { |
| 449 | result[currentName] = strings.TrimRight(currentValue, " \t\r\n") |
| 450 | currentName = "" |
| 451 | currentValue = "" |
| 452 | } else if len(currentName) > 0 { |
| 453 | currentValue += line + "\n" |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | return result, nil |
| 458 | } |
| 459 | |
| 460 | func (t TypeScriptify) backup(fileName string) error { |
| 461 | fileIn, err := os.Open(fileName) |
no test coverage detected
searching dependent graphs…