( opts: DetectOptions, )
| 29 | * - 'managed' is the catch-all for installs we can't safely modify. |
| 30 | */ |
| 31 | export const detectInstallMethod = async ( |
| 32 | opts: DetectOptions, |
| 33 | ): Promise<Exclude<InstallMethod, 'auto'>> => { |
| 34 | if (opts.override !== 'auto') return opts.override; |
| 35 | |
| 36 | const dockerEnv = opts.dockerEnvPath ?? '/.dockerenv'; |
| 37 | if (await exists(dockerEnv)) return 'docker'; |
| 38 | |
| 39 | const gitDir = path.join(opts.rootDir, '.git'); |
| 40 | if (await exists(gitDir) && await writable(opts.rootDir)) return 'git'; |
| 41 | |
| 42 | const lockfile = path.join(opts.rootDir, 'package-lock.json'); |
| 43 | if (await exists(lockfile) && await writable(lockfile)) return 'npm'; |
| 44 | |
| 45 | return 'managed'; |
| 46 | }; |
no test coverage detected