UNPKG

2.02 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getYarnVersionIfAvailable = getYarnVersionIfAvailable;
7exports.isProjectUsingYarn = isProjectUsingYarn;
8
9function _child_process() {
10 const data = require("child_process");
11
12 _child_process = function () {
13 return data;
14 };
15
16 return data;
17}
18
19function _semver() {
20 const data = _interopRequireDefault(require("semver"));
21
22 _semver = function () {
23 return data;
24 };
25
26 return data;
27}
28
29function _cliTools() {
30 const data = require("@react-native-community/cli-tools");
31
32 _cliTools = function () {
33 return data;
34 };
35
36 return data;
37}
38
39function _findUp() {
40 const data = _interopRequireDefault(require("find-up"));
41
42 _findUp = function () {
43 return data;
44 };
45
46 return data;
47}
48
49function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
51/**
52 * Copyright (c) Facebook, Inc. and its affiliates.
53 *
54 * This source code is licensed under the MIT license found in the
55 * LICENSE file in the root directory of this source tree.
56 *
57 */
58
59/**
60 * Use Yarn if available, it's much faster than the npm client.
61 * Return the version of yarn installed on the system, null if yarn is not available.
62 */
63function getYarnVersionIfAvailable() {
64 let yarnVersion;
65
66 try {
67 // execSync returns a Buffer -> convert to string
68 yarnVersion = ((0, _child_process().execSync)('yarn --version', {
69 stdio: [0, 'pipe', 'ignore']
70 }).toString() || '').trim();
71 } catch (error) {
72 return null;
73 } // yarn < 0.16 has a 'missing manifest' bug
74
75
76 try {
77 if (_semver().default.gte(yarnVersion, '0.16.0')) {
78 return yarnVersion;
79 }
80
81 return null;
82 } catch (error) {
83 _cliTools().logger.error(`Cannot parse yarn version: ${yarnVersion}`);
84
85 return null;
86 }
87}
88/**
89 * Check if project is using Yarn (has `yarn.lock` in the tree)
90 */
91
92
93function isProjectUsingYarn(cwd) {
94 return _findUp().default.sync('yarn.lock', {
95 cwd
96 });
97}
98
99//# sourceMappingURL=yarn.js.map
\No newline at end of file