index.js 625 B

1234567891011121314151617181920212223242526272829
  1. /*!
  2. * global-modules <https://github.com/jonschlinkert/global-modules>
  3. *
  4. * Copyright (c) 2015-2017 Jon Schlinkert.
  5. * Licensed under the MIT license.
  6. */
  7. 'use strict';
  8. const path = require('path');
  9. const prefix = require('global-prefix');
  10. let gm;
  11. function getPath() {
  12. if (process.platform === 'win32' || process.env.OSTYPE === 'msys' || process.env.OSTYPE === 'cygwin') {
  13. return path.resolve(prefix, 'node_modules');
  14. }
  15. return path.resolve(prefix, 'lib/node_modules');
  16. }
  17. /**
  18. * Expose `global-modules` path
  19. */
  20. Reflect.defineProperty(module, 'exports', {
  21. get() {
  22. return gm || (gm = getPath());
  23. }
  24. });