defaults.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. // Generated with `lib/make.js`
  2. /* eslint-disable no-useless-concat */
  3. "use strict";
  4. const os = require("os");
  5. const path = require("path");
  6. const temp = os.tmpdir();
  7. const uidOrPid = process.getuid ? process.getuid() : process.pid;
  8. const hasUnicode = () => true;
  9. const isWindows = process.platform === "win32";
  10. const osenv = {
  11. editor: () => process.env.EDITOR || process.env.VISUAL || (isWindows ? "notepad.exe" : "vi"),
  12. shell: () => (isWindows ? process.env.COMSPEC || "cmd.exe" : process.env.SHELL || "/bin/bash"),
  13. };
  14. const umask = {
  15. fromString: () => process.umask(),
  16. };
  17. let home = os.homedir();
  18. if (home) {
  19. process.env.HOME = home;
  20. } else {
  21. home = path.resolve(temp, `npm-${uidOrPid}`);
  22. }
  23. const cacheExtra = process.platform === "win32" ? "npm-cache" : ".npm";
  24. const cacheRoot = (process.platform === "win32" && process.env.APPDATA) || home;
  25. const cache = path.resolve(cacheRoot, cacheExtra);
  26. let defaults;
  27. let globalPrefix;
  28. Object.defineProperty(exports, "defaults", {
  29. get() {
  30. if (defaults) {
  31. return defaults;
  32. }
  33. if (process.env.PREFIX) {
  34. globalPrefix = process.env.PREFIX;
  35. } else if (process.platform === "win32") {
  36. // c:\node\node.exe --> prefix=c:\node\
  37. globalPrefix = path.dirname(process.execPath);
  38. } else {
  39. // /usr/local/bin/node --> prefix=/usr/local
  40. globalPrefix = path.dirname(path.dirname(process.execPath)); // destdir only is respected on Unix
  41. if (process.env.DESTDIR) {
  42. globalPrefix = path.join(process.env.DESTDIR, globalPrefix);
  43. }
  44. }
  45. defaults = {
  46. access: null,
  47. "allow-same-version": false,
  48. "always-auth": false,
  49. also: null,
  50. audit: true,
  51. "audit-level": "low",
  52. "auth-type": "legacy",
  53. "bin-links": true,
  54. browser: null,
  55. ca: null,
  56. cafile: null,
  57. cache,
  58. "cache-lock-stale": 60000,
  59. "cache-lock-retries": 10,
  60. "cache-lock-wait": 10000,
  61. "cache-max": Infinity,
  62. "cache-min": 10,
  63. cert: null,
  64. cidr: null,
  65. color: process.env.NO_COLOR == null,
  66. depth: Infinity,
  67. description: true,
  68. dev: false,
  69. "dry-run": false,
  70. editor: osenv.editor(),
  71. "engine-strict": false,
  72. force: false,
  73. "fetch-retries": 2,
  74. "fetch-retry-factor": 10,
  75. "fetch-retry-mintimeout": 10000,
  76. "fetch-retry-maxtimeout": 60000,
  77. git: "git",
  78. "git-tag-version": true,
  79. "commit-hooks": true,
  80. global: false,
  81. globalconfig: path.resolve(globalPrefix, "etc", "npmrc"),
  82. "global-style": false,
  83. group: process.platform === "win32" ? 0 : process.env.SUDO_GID || (process.getgid && process.getgid()),
  84. "ham-it-up": false,
  85. heading: "npm",
  86. "if-present": false,
  87. "ignore-prepublish": false,
  88. "ignore-scripts": false,
  89. "init-module": path.resolve(home, ".npm-init.js"),
  90. "init-author-name": "",
  91. "init-author-email": "",
  92. "init-author-url": "",
  93. "init-version": "1.0.0",
  94. "init-license": "ISC",
  95. json: false,
  96. key: null,
  97. "legacy-bundling": false,
  98. link: false,
  99. "local-address": undefined,
  100. loglevel: "notice",
  101. logstream: process.stderr,
  102. "logs-max": 10,
  103. long: false,
  104. maxsockets: 50,
  105. message: "%s",
  106. "metrics-registry": null,
  107. "node-options": null,
  108. "node-version": process.version,
  109. offline: false,
  110. "onload-script": false,
  111. only: null,
  112. optional: true,
  113. otp: undefined,
  114. "package-lock": true,
  115. "package-lock-only": false,
  116. parseable: false,
  117. "prefer-offline": false,
  118. "prefer-online": false,
  119. prefix: globalPrefix,
  120. preid: "",
  121. production: process.env.NODE_ENV === "production",
  122. progress: !process.env.TRAVIS && !process.env.CI,
  123. proxy: null,
  124. "https-proxy": null,
  125. noproxy: null,
  126. "user-agent": "npm/{npm-version} " + "node/{node-version} " + "{platform} " + "{arch}",
  127. "read-only": false,
  128. "rebuild-bundle": true,
  129. registry: "https://registry.npmjs.org/",
  130. rollback: true,
  131. save: true,
  132. "save-bundle": false,
  133. "save-dev": false,
  134. "save-exact": false,
  135. "save-optional": false,
  136. "save-prefix": "^",
  137. "save-prod": false,
  138. scope: "",
  139. "script-shell": null,
  140. "scripts-prepend-node-path": "warn-only",
  141. searchopts: "",
  142. searchexclude: null,
  143. searchlimit: 20,
  144. searchstaleness: 15 * 60,
  145. "send-metrics": false,
  146. shell: osenv.shell(),
  147. shrinkwrap: true,
  148. "sign-git-commit": false,
  149. "sign-git-tag": false,
  150. "sso-poll-frequency": 500,
  151. "sso-type": "oauth",
  152. "strict-ssl": true,
  153. tag: "latest",
  154. "tag-version-prefix": "v",
  155. timing: false,
  156. tmp: temp,
  157. unicode: hasUnicode(),
  158. "unsafe-perm":
  159. process.platform === "win32" ||
  160. process.platform === "cygwin" ||
  161. !(process.getuid && process.setuid && process.getgid && process.setgid) ||
  162. process.getuid() !== 0,
  163. "update-notifier": true,
  164. usage: false,
  165. user: process.platform === "win32" || os.type() === "OS400" ? 0 : "nobody",
  166. userconfig: path.resolve(home, ".npmrc"),
  167. umask: process.umask ? process.umask() : umask.fromString("022"),
  168. version: false,
  169. versions: false,
  170. viewer: process.platform === "win32" ? "browser" : "man",
  171. _exit: true,
  172. };
  173. return defaults;
  174. },
  175. });