( cwd: string )
| 64 | * Returns null otherwise. |
| 65 | */ |
| 66 | export async function tryDetectServices( |
| 67 | cwd: string |
| 68 | ): Promise<DetectServicesResult | null> { |
| 69 | const isServicesEnabled = await isExperimentalServicesEnabled(cwd); |
| 70 | if (!isServicesEnabled) { |
| 71 | return null; |
| 72 | } |
| 73 | |
| 74 | const fs = new LocalFileSystemDetector(cwd); |
| 75 | const result = await detectServices({ |
| 76 | fs, |
| 77 | detectEntrypoint: createDetectEntrypoint(cwd), |
| 78 | }); |
| 79 | |
| 80 | // No services configured |
| 81 | const hasNoServicesError = result.errors.some( |
| 82 | e => e.code === 'NO_EXPERIMENTAL_SERVICES_CONFIGURED' |
| 83 | ); |
| 84 | if (hasNoServicesError) { |
| 85 | return null; |
| 86 | } |
| 87 | |
| 88 | return result; |
| 89 | } |
| 90 | |
| 91 | export async function writeServicesConfig( |
| 92 | cwd: string, |
no test coverage detected