extractFilePathFromStdin reads JSON from stdin and extracts file_path
()
| 1349 | |
| 1350 | // extractFilePathFromStdin reads JSON from stdin and extracts file_path |
| 1351 | func extractFilePathFromStdin() (string, error) { |
| 1352 | input, err := io.ReadAll(os.Stdin) |
| 1353 | if err != nil { |
| 1354 | return "", err |
| 1355 | } |
| 1356 | |
| 1357 | var data map[string]interface{} |
| 1358 | if err := json.Unmarshal(input, &data); err != nil { |
| 1359 | // Try regex fallback for non-JSON or partial JSON |
| 1360 | re := regexp.MustCompile(`"file_path"\s*:\s*"([^"]+)"`) |
| 1361 | matches := re.FindSubmatch(input) |
| 1362 | if len(matches) >= 2 { |
| 1363 | return string(matches[1]), nil |
| 1364 | } |
| 1365 | return "", err |
| 1366 | } |
| 1367 | |
| 1368 | filePath, ok := data["file_path"].(string) |
| 1369 | if !ok { |
| 1370 | return "", nil |
| 1371 | } |
| 1372 | |
| 1373 | return filePath, nil |
| 1374 | } |
| 1375 | |
| 1376 | // checkFileImporters checks if a file is a hub and shows its importers |
| 1377 | func checkFileImporters(root, filePath string) error { |
no outgoing calls