pubspecHasFlutterWebTarget returns true if "web:" is nested under "flutter:" in pubspec.yaml.
(data string)
| 364 | |
| 365 | // pubspecHasFlutterWebTarget returns true if "web:" is nested under "flutter:" in pubspec.yaml. |
| 366 | func pubspecHasFlutterWebTarget(data string) bool { |
| 367 | inFlutterSection := false |
| 368 | for _, line := range strings.Split(data, "\n") { |
| 369 | trimmed := strings.TrimSpace(line) |
| 370 | if trimmed == "" || strings.HasPrefix(trimmed, "#") { |
| 371 | continue |
| 372 | } |
| 373 | // A line with no leading whitespace is a top-level YAML key. |
| 374 | isTopLevel := len(line) > 0 && line[0] != ' ' && line[0] != '\t' |
| 375 | if isTopLevel { |
| 376 | inFlutterSection = strings.HasPrefix(line, "flutter:") |
| 377 | continue |
| 378 | } |
| 379 | if inFlutterSection && strings.HasPrefix(trimmed, "web:") { |
| 380 | return true |
| 381 | } |
| 382 | } |
| 383 | return false |
| 384 | } |
| 385 | |
| 386 | func dirExists(dir, name string) bool { |
| 387 | info, err := os.Stat(filepath.Join(dir, name)) |