MCPcopy
hub / github.com/yarnpkg/yarn / getInstallationMethod

Function getInstallationMethod

src/util/yarn-version.js:15–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13export {version};
14
15export 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
40export type InstallationMethod =
41 | 'tar'

Callers 1

_checkUpdateMethod · 0.90

Calls 1

readJsonFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…