index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1682324647470, function(require, module, exports) {
  8. module.exports = realpath
  9. realpath.realpath = realpath
  10. realpath.sync = realpathSync
  11. realpath.realpathSync = realpathSync
  12. realpath.monkeypatch = monkeypatch
  13. realpath.unmonkeypatch = unmonkeypatch
  14. var fs = require('fs')
  15. var origRealpath = fs.realpath
  16. var origRealpathSync = fs.realpathSync
  17. var version = process.version
  18. var ok = /^v[0-5]\./.test(version)
  19. var old = require('./old.js')
  20. function newError (er) {
  21. return er && er.syscall === 'realpath' && (
  22. er.code === 'ELOOP' ||
  23. er.code === 'ENOMEM' ||
  24. er.code === 'ENAMETOOLONG'
  25. )
  26. }
  27. function realpath (p, cache, cb) {
  28. if (ok) {
  29. return origRealpath(p, cache, cb)
  30. }
  31. if (typeof cache === 'function') {
  32. cb = cache
  33. cache = null
  34. }
  35. origRealpath(p, cache, function (er, result) {
  36. if (newError(er)) {
  37. old.realpath(p, cache, cb)
  38. } else {
  39. cb(er, result)
  40. }
  41. })
  42. }
  43. function realpathSync (p, cache) {
  44. if (ok) {
  45. return origRealpathSync(p, cache)
  46. }
  47. try {
  48. return origRealpathSync(p, cache)
  49. } catch (er) {
  50. if (newError(er)) {
  51. return old.realpathSync(p, cache)
  52. } else {
  53. throw er
  54. }
  55. }
  56. }
  57. function monkeypatch () {
  58. fs.realpath = realpath
  59. fs.realpathSync = realpathSync
  60. }
  61. function unmonkeypatch () {
  62. fs.realpath = origRealpath
  63. fs.realpathSync = origRealpathSync
  64. }
  65. }, function(modId) {var map = {"./old.js":1682324647471}; return __REQUIRE__(map[modId], modId); })
  66. __DEFINE__(1682324647471, function(require, module, exports) {
  67. // Copyright Joyent, Inc. and other Node contributors.
  68. //
  69. // Permission is hereby granted, free of charge, to any person obtaining a
  70. // copy of this software and associated documentation files (the
  71. // "Software"), to deal in the Software without restriction, including
  72. // without limitation the rights to use, copy, modify, merge, publish,
  73. // distribute, sublicense, and/or sell copies of the Software, and to permit
  74. // persons to whom the Software is furnished to do so, subject to the
  75. // following conditions:
  76. //
  77. // The above copyright notice and this permission notice shall be included
  78. // in all copies or substantial portions of the Software.
  79. //
  80. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  81. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  82. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  83. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  84. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  85. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  86. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  87. var pathModule = require('path');
  88. var isWindows = process.platform === 'win32';
  89. var fs = require('fs');
  90. // JavaScript implementation of realpath, ported from node pre-v6
  91. var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
  92. function rethrow() {
  93. // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
  94. // is fairly slow to generate.
  95. var callback;
  96. if (DEBUG) {
  97. var backtrace = new Error;
  98. callback = debugCallback;
  99. } else
  100. callback = missingCallback;
  101. return callback;
  102. function debugCallback(err) {
  103. if (err) {
  104. backtrace.message = err.message;
  105. err = backtrace;
  106. missingCallback(err);
  107. }
  108. }
  109. function missingCallback(err) {
  110. if (err) {
  111. if (process.throwDeprecation)
  112. throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
  113. else if (!process.noDeprecation) {
  114. var msg = 'fs: missing callback ' + (err.stack || err.message);
  115. if (process.traceDeprecation)
  116. console.trace(msg);
  117. else
  118. console.error(msg);
  119. }
  120. }
  121. }
  122. }
  123. function maybeCallback(cb) {
  124. return typeof cb === 'function' ? cb : rethrow();
  125. }
  126. var normalize = pathModule.normalize;
  127. // Regexp that finds the next partion of a (partial) path
  128. // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
  129. if (isWindows) {
  130. var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
  131. } else {
  132. var nextPartRe = /(.*?)(?:[\/]+|$)/g;
  133. }
  134. // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
  135. if (isWindows) {
  136. var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
  137. } else {
  138. var splitRootRe = /^[\/]*/;
  139. }
  140. exports.realpathSync = function realpathSync(p, cache) {
  141. // make p is absolute
  142. p = pathModule.resolve(p);
  143. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  144. return cache[p];
  145. }
  146. var original = p,
  147. seenLinks = {},
  148. knownHard = {};
  149. // current character position in p
  150. var pos;
  151. // the partial path so far, including a trailing slash if any
  152. var current;
  153. // the partial path without a trailing slash (except when pointing at a root)
  154. var base;
  155. // the partial path scanned in the previous round, with slash
  156. var previous;
  157. start();
  158. function start() {
  159. // Skip over roots
  160. var m = splitRootRe.exec(p);
  161. pos = m[0].length;
  162. current = m[0];
  163. base = m[0];
  164. previous = '';
  165. // On windows, check that the root exists. On unix there is no need.
  166. if (isWindows && !knownHard[base]) {
  167. fs.lstatSync(base);
  168. knownHard[base] = true;
  169. }
  170. }
  171. // walk down the path, swapping out linked pathparts for their real
  172. // values
  173. // NB: p.length changes.
  174. while (pos < p.length) {
  175. // find the next part
  176. nextPartRe.lastIndex = pos;
  177. var result = nextPartRe.exec(p);
  178. previous = current;
  179. current += result[0];
  180. base = previous + result[1];
  181. pos = nextPartRe.lastIndex;
  182. // continue if not a symlink
  183. if (knownHard[base] || (cache && cache[base] === base)) {
  184. continue;
  185. }
  186. var resolvedLink;
  187. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  188. // some known symbolic link. no need to stat again.
  189. resolvedLink = cache[base];
  190. } else {
  191. var stat = fs.lstatSync(base);
  192. if (!stat.isSymbolicLink()) {
  193. knownHard[base] = true;
  194. if (cache) cache[base] = base;
  195. continue;
  196. }
  197. // read the link if it wasn't read before
  198. // dev/ino always return 0 on windows, so skip the check.
  199. var linkTarget = null;
  200. if (!isWindows) {
  201. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  202. if (seenLinks.hasOwnProperty(id)) {
  203. linkTarget = seenLinks[id];
  204. }
  205. }
  206. if (linkTarget === null) {
  207. fs.statSync(base);
  208. linkTarget = fs.readlinkSync(base);
  209. }
  210. resolvedLink = pathModule.resolve(previous, linkTarget);
  211. // track this, if given a cache.
  212. if (cache) cache[base] = resolvedLink;
  213. if (!isWindows) seenLinks[id] = linkTarget;
  214. }
  215. // resolve the link, then start over
  216. p = pathModule.resolve(resolvedLink, p.slice(pos));
  217. start();
  218. }
  219. if (cache) cache[original] = p;
  220. return p;
  221. };
  222. exports.realpath = function realpath(p, cache, cb) {
  223. if (typeof cb !== 'function') {
  224. cb = maybeCallback(cache);
  225. cache = null;
  226. }
  227. // make p is absolute
  228. p = pathModule.resolve(p);
  229. if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
  230. return process.nextTick(cb.bind(null, null, cache[p]));
  231. }
  232. var original = p,
  233. seenLinks = {},
  234. knownHard = {};
  235. // current character position in p
  236. var pos;
  237. // the partial path so far, including a trailing slash if any
  238. var current;
  239. // the partial path without a trailing slash (except when pointing at a root)
  240. var base;
  241. // the partial path scanned in the previous round, with slash
  242. var previous;
  243. start();
  244. function start() {
  245. // Skip over roots
  246. var m = splitRootRe.exec(p);
  247. pos = m[0].length;
  248. current = m[0];
  249. base = m[0];
  250. previous = '';
  251. // On windows, check that the root exists. On unix there is no need.
  252. if (isWindows && !knownHard[base]) {
  253. fs.lstat(base, function(err) {
  254. if (err) return cb(err);
  255. knownHard[base] = true;
  256. LOOP();
  257. });
  258. } else {
  259. process.nextTick(LOOP);
  260. }
  261. }
  262. // walk down the path, swapping out linked pathparts for their real
  263. // values
  264. function LOOP() {
  265. // stop if scanned past end of path
  266. if (pos >= p.length) {
  267. if (cache) cache[original] = p;
  268. return cb(null, p);
  269. }
  270. // find the next part
  271. nextPartRe.lastIndex = pos;
  272. var result = nextPartRe.exec(p);
  273. previous = current;
  274. current += result[0];
  275. base = previous + result[1];
  276. pos = nextPartRe.lastIndex;
  277. // continue if not a symlink
  278. if (knownHard[base] || (cache && cache[base] === base)) {
  279. return process.nextTick(LOOP);
  280. }
  281. if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
  282. // known symbolic link. no need to stat again.
  283. return gotResolvedLink(cache[base]);
  284. }
  285. return fs.lstat(base, gotStat);
  286. }
  287. function gotStat(err, stat) {
  288. if (err) return cb(err);
  289. // if not a symlink, skip to the next path part
  290. if (!stat.isSymbolicLink()) {
  291. knownHard[base] = true;
  292. if (cache) cache[base] = base;
  293. return process.nextTick(LOOP);
  294. }
  295. // stat & read the link if not read before
  296. // call gotTarget as soon as the link target is known
  297. // dev/ino always return 0 on windows, so skip the check.
  298. if (!isWindows) {
  299. var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
  300. if (seenLinks.hasOwnProperty(id)) {
  301. return gotTarget(null, seenLinks[id], base);
  302. }
  303. }
  304. fs.stat(base, function(err) {
  305. if (err) return cb(err);
  306. fs.readlink(base, function(err, target) {
  307. if (!isWindows) seenLinks[id] = target;
  308. gotTarget(err, target);
  309. });
  310. });
  311. }
  312. function gotTarget(err, target, base) {
  313. if (err) return cb(err);
  314. var resolvedLink = pathModule.resolve(previous, target);
  315. if (cache) cache[base] = resolvedLink;
  316. gotResolvedLink(resolvedLink);
  317. }
  318. function gotResolvedLink(resolvedLink) {
  319. // resolve the link, then start over
  320. p = pathModule.resolve(resolvedLink, p.slice(pos));
  321. start();
  322. }
  323. };
  324. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  325. return __REQUIRE__(1682324647470);
  326. })()
  327. //miniprogram-npm-outsideDeps=["fs","path"]
  328. //# sourceMappingURL=index.js.map