()
| 13 | export {version}; |
| 14 | |
| 15 | export async function getInstallationMethod(): Promise<InstallationMethod> { |
| 16 | let installationMethod = originalInstallationMethod; |
| 17 | |
| 18 | // If there's a package.json in the parent directory, it could have an |
| 19 | // override for the installation method, so we should prefer that over |
| 20 | // whatever was originally in Yarn's package.json. This is the case with |
| 21 | // systems such as Homebrew, which take the tarball and modify the |
| 22 | // installation method so we're aware of the fact that Yarn was installed via |
| 23 | // Homebrew (so things like update notifications can point out the correct |
| 24 | // command to upgrade). |
| 25 | try { |
| 26 | const manifestPath = path.join(__dirname, '..', 'package.json'); |
| 27 | if (fs.existsSync(manifestPath)) { |
| 28 | // non-async version is deprecated |
| 29 | const manifest = await readJson(manifestPath); |
| 30 | if (manifest.installationMethod) { |
| 31 | installationMethod = manifest.installationMethod; |
| 32 | } |
| 33 | } |
| 34 | } catch (e) { |
| 35 | // Ignore any errors; this is not critical functionality. |
| 36 | } |
| 37 | return installationMethod; |
| 38 | } |
| 39 | |
| 40 | export type InstallationMethod = |
| 41 | | 'tar' |
no test coverage detected
searching dependent graphs…