rsnext/packages/next/compiled/find-cache-dir/index.js

1 line
3.6 KiB
JavaScript
Raw Normal View History

module.exports=function(r,t){"use strict";var e={};function __webpack_require__(t){if(e[t]){return e[t].exports}var n=e[t]={i:t,l:false,exports:{}};r[t].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(472)}return startup()}({67:function(r,t,e){var n=e(622);r.exports=function(r,t){if(t){var e=t.map(function(t){return n.resolve(r,t)})}else{var e=r}var o=e.slice(1).reduce(function(r,t){if(!t.match(/^([A-Za-z]:)?\/|\\/)){throw new Error("relative path without a basedir")}var e=t.split(/\/+|\\+/);for(var n=0;r[n]===e[n]&&n<Math.min(r.length,e.length);n++);return r.slice(0,n)},e[0].split(/\/+|\\+/));return o.length>1?o.join("/"):"/"}},140:function(r,t,e){"use strict";const n=e(622);const o=e(442);const s=async r=>{const t=await o("package.json",{cwd:r});return t&&n.dirname(t)};r.exports=s;r.exports.default=s;r.exports.sync=(r=>{const t=o.sync("package.json",{cwd:r});return t&&n.dirname(t)})},442:function(r){r.exports=require("next/dist/compiled/find-up")},472:function(r,t,e){"use strict";const n=e(622);const o=e(747);const s=e(67);const c=e(140);const i=e(829);const{env:u,cwd:a}=process;const d=r=>{try{o.accessSync(r,o.constants.W_OK);return true}catch(r){return false}};function useDirectory(r,t){if(t.create){i.sync(r)}if(t.thunk){return(...t)=>n.join(r,...t)}return r}function getNodeModuleDirectory(r){const t=n.join(r,"node_modules");if(!d(t)&&(o.existsSync(t)||!d(n.join(r)))){return}return t}r.exports=((r={})=>{if(u.CACHE_DIR&&!["true","false","1","0"].includes(u.CACHE_DIR)){return useDirectory(n.join(u.CACHE_DIR,"find-cache-dir"),r)}let{cwd:t=a()}=r;if(r.files){t=s(t,r.files)}t=c.sync(t);if(!t){return}const e=getNodeModuleDirectory(t);if(!e){return undefined}return useDirectory(n.join(t,"node_modules",".cache",r.name),r)})},519:function(r){r.exports=require("next/dist/compiled/semver")},622:function(r){r.exports=require("path")},669:function(r){r.exports=require("util")},747:function(r){r.exports=require("fs")},829:function(r,t,e){"use strict";const n=e(747);const o=e(622);const{promisify:s}=e(669);const c=e(519);const i=c.satisfies(process.version,">=10.12.0");const u=r=>{if(process.platform==="win32"){const t=/[<>:"|?*]/.test(r.replace(o.parse(r).root,""));if(t){const t=new Error(`Path contains invalid characters: ${r}`);t.code="EINVAL";throw t}}};const a=r=>{const t={mode:511&~process.umask(),fs:n};return{...t,...r}};const d=r=>{const t=new Error(`operation not permitted, mkdir '${r}'`);t.code="EPERM";t.errno=-4048;t.path=r;t.syscall="mkdir";return t};const f=async(r,t)=>{u(r);t=a(t);const e=s(t.fs.mkdir);const c=s(t.fs.stat);if(i&&t.fs.mkdir===n.mkdir){const n=o.resolve(r);await e(n,{mode:t.mode,recursive:true});return n}const f=async r=>{try{await e(r,t.mode);return r}catch(t){if(t.code==="EPERM"){throw t}if(t.code==="ENOENT"){if(o.dirname(r)===r){throw d(r)}if(t.message.includes("null bytes")){throw t}await f(o.dirname(r));return f(r)}try{const e=await c(r);if(!e.isDirectory()){throw new Error("The path is not a directory")}}catch(r){throw t}return r}};return f(o.resolve(r))};r.exports=f;r.exports.sync=((r,t)=>{u(r);t=a(t);if(i&&t.fs.mkdirSync===n.mkdirSync){const e=o.resolve(r);n.mkdirSync(e,{mode:t.mode,recursive:true});return e}const e=r=>{try{t.fs.mkdirSync(r,t.mode)}catch(n){if(n.code==="EPERM"){throw n}if(n.code==="ENOENT"){if(o.dirname(r)===r){throw d(r)}if(n.message.includes("null bytes")){throw n}e(o.dirname(r));return e(r)}try{if(!t.fs.statSync(r).isDirectory()){throw new Error("The path is not a directory")}}catch(r){throw n}}return r};return e(o.resolve(r))})}});