yarn.js 2.0 KB

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