MCPcopy
hub / github.com/vercel/next.js / readdirSync

Function readdirSync

packages/next/src/compiled/@vercel/nft/index.js:13–13  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

11 * Copyright (c) 2014-present, Jon Schlinkert.
12 * Released under the MIT License.
13 */e.exports=function(e){if(typeof e==="number"){return e-e===0}if(typeof e==="string"&&e.trim()!==""){return Number.isFinite?Number.isFinite(+e):isFinite(+e)}return false}},1551:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return t.call(e)=="[object Array]"}},1065:(e,t,r)=>{"use strict";const s=r(3837);const a=r(8333);const o=r(3423);const u=r(5502);const isEmptyString=e=>e===""||e==="./";const micromatch=(e,t,r)=>{t=[].concat(t);e=[].concat(e);let s=new Set;let a=new Set;let u=new Set;let c=0;let onResult=e=>{u.add(e.output);if(r&&r.onResult){r.onResult(e)}};for(let u=0;u<t.length;u++){let f=o(String(t[u]),{...r,onResult:onResult},true);let d=f.state.negated||f.state.negatedExtglob;if(d)c++;for(let t of e){let e=f(t,true);let r=d?!e.isMatch:e.isMatch;if(!r)continue;if(d){s.add(e.output)}else{s.delete(e.output);a.add(e.output)}}}let f=c===t.length?[...u]:[...a];let d=f.filter((e=>!s.has(e)));if(r&&d.length===0){if(r.failglob===true){throw new Error(`No matches found for "${t.join(", ")}"`)}if(r.nonull===true||r.nullglob===true){return r.unescape?t.map((e=>e.replace(/\\/g,""))):t}}return d};micromatch.match=micromatch;micromatch.matcher=(e,t)=>o(e,t);micromatch.isMatch=(e,t,r)=>o(t,r)(e);micromatch.any=micromatch.isMatch;micromatch.not=(e,t,r={})=>{t=[].concat(t).map(String);let s=new Set;let a=[];let onResult=e=>{if(r.onResult)r.onResult(e);a.push(e.output)};let o=new Set(micromatch(e,t,{...r,onResult:onResult}));for(let e of a){if(!o.has(e)){s.add(e)}}return[...s]};micromatch.contains=(e,t,r)=>{if(typeof e!=="string"){throw new TypeError(`Expected a string: "${s.inspect(e)}"`)}if(Array.isArray(t)){return t.some((t=>micromatch.contains(e,t,r)))}if(typeof t==="string"){if(isEmptyString(e)||isEmptyString(t)){return false}if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t)){return true}}return micromatch.isMatch(e,t,{...r,contains:true})};micromatch.matchKeys=(e,t,r)=>{if(!u.isObject(e)){throw new TypeError("Expected the first argument to be an object")}let s=micromatch(Object.keys(e),t,r);let a={};for(let t of s)a[t]=e[t];return a};micromatch.some=(e,t,r)=>{let s=[].concat(e);for(let e of[].concat(t)){let t=o(String(e),r);if(s.some((e=>t(e)))){return true}}return false};micromatch.every=(e,t,r)=>{let s=[].concat(e);for(let e of[].concat(t)){let t=o(String(e),r);if(!s.every((e=>t(e)))){return false}}return true};micromatch.all=(e,t,r)=>{if(typeof e!=="string"){throw new TypeError(`Expected a string: "${s.inspect(e)}"`)}return[].concat(t).every((t=>o(t,r)(e)))};micromatch.capture=(e,t,r)=>{let s=u.isWindows(r);let a=o.makeRe(String(e),{...r,capture:true});let c=a.exec(s?u.toPosixSlashes(t):t);if(c){return c.slice(1).map((e=>e===void 0?"":e))}};micromatch.makeRe=(...e)=>o.makeRe(...e);micromatch.scan=(...e)=>o.scan(...e);micromatch.parse=(e,t)=>{let r=[];for(let s of[].concat(e||[])){for(let e of a(String(s),t)){r.push(o.parse(e,t))}}return r};micromatch.braces=(e,t)=>{if(typeof e!=="string")throw new TypeError("Expected a string");if(t&&t.nobrace===true||!/\{.*\}/.test(e)){return[e]}return a(e,t)};micromatch.braceExpand=(e,t)=>{if(typeof e!=="string")throw new TypeError("Expected a string");return micromatch.braces(e,{...t,expand:true})};e.exports=micromatch},9042:(e,t,r)=>{if(typeof process.addon==="function"){e.exports=process.addon.bind(process)}else{e.exports=r(5850)}},5850:(module,__unused_webpack_exports,__nccwpck_require__)=>{var fs=__nccwpck_require__(7147);var path=__nccwpck_require__(1017);var os=__nccwpck_require__(2037);var runtimeRequire=true?eval("require"):0;var vars=process.config&&process.config.variables||{};var prebuildsOnly=!!process.env.PREBUILDS_ONLY;var abi=process.versions.modules;var runtime=isElectron()?"electron":isNwjs()?"node-webkit":"node";var arch=process.env.npm_config_arch||os.arch();var platform=process.env.npm_config_platform||os.platform();var libc=process.env.LIBC||(isAlpine(platform)?"musl":"glibc");var armv=process.env.ARM_VERSION||(arch==="arm64"?"8":vars.arm_version)||"";var uv=(process.versions.uv||"").split(".")[0];module.exports=load;function load(e){return runtimeRequire(load.resolve(e))}load.resolve=load.path=function(e){e=path.resolve(e||".");try{var t=runtimeRequire(path.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");if(process.env[t+"_PREBUILD"])e=process.env[t+"_PREBUILD"]}catch(e){}if(!prebuildsOnly){var r=getFirst(path.join(e,"build/Release"),matchBuild);if(r)return r;var s=getFirst(path.join(e,"build/Debug"),matchBuild);if(s)return s}var a=resolve(e);if(a)return a;var o=resolve(path.dirname(process.execPath));if(o)return o;var u=["platform="+platform,"arch="+arch,"runtime="+runtime,"abi="+abi,"uv="+uv,armv?"armv="+armv:"","libc="+libc,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",true?"webpack=true":0].filter(Boolean).join(" ");throw new Error("No native build was found for "+u+"\n loaded from: "+e+"\n");function resolve(e){var t=readdirSync(path.join(e,"prebuilds")).map(parseTuple);var r=t.filter(matchTuple(platform,arch)).sort(compareTuples)[0];if(!r)return;var s=path.join(e,"prebuilds",r.name);var a=readdirSync(s).map(parseTags);var o=a.filter(matchTags(runtime,abi));var u=o.sort(compareTags(runtime))[0];if(u)return path.join(s,u.file)}};function readdirSync(e){try{return fs.readdirSync(e)}catch(e){return[]}}function getFirst(e,t){var r=readdirSync(e).filter(t);return r[0]&&path.join(e,r[0])}function matchBuild(e){return/\.node$/.test(e)}function parseTuple(e){var t=e.split("-");if(t.length!==2)return;var r=t[0];var s=t[1].split("+");if(!r)return;if(!s.length)return;if(!s.every(Boolean))return;return{name:e,platform:r,architectures:s}}function matchTuple(e,t){return function(r){if(r==null)return false;if(r.platform!==e)return false;return r.architectures.includes(t)}}function compareTuples(e,t){return e.architectures.length-t.architectures.length}function parseTags(e){var t=e.split(".");var r=t.pop();var s={file:e,specificity:0};if(r!=="node")return;for(var a=0;a<t.length;a++){var o=t[a];if(o==="node"||o==="electron"||o==="node-webkit"){s.runtime=o}else if(o==="napi"){s.napi=true}else if(o.slice(0,3)==="abi"){s.abi=o.slice(3)}else if(o.slice(0,2)==="uv"){s.uv=o.slice(2)}else if(o.slice(0,4)==="armv"){s.armv=o.slice(4)}else if(o==="glibc"||o==="musl"){s.libc=o}else{continue}s.specificity++}return s}function matchTags(e,t){return function(r){if(r==null)return false;if(r.runtime!==e&&!runtimeAgnostic(r))return false;if(r.abi!==t&&!r.napi)return false;if(r.uv&&r.uv!==uv)return false;if(r.armv&&r.armv!==armv)return false;if(r.libc&&r.libc!==libc)return false;return true}}function runtimeAgnostic(e){return e.runtime==="node"&&e.napi}function compareTags(e){return function(t,r){if(t.runtime!==r.runtime){return t.runtime===e?-1:1}else if(t.abi!==r.abi){return t.abi?-1:1}else if(t.specificity!==r.specificity){return t.specificity>r.specificity?-1:1}else{return 0}}}function isNwjs(){return!!(process.versions&&process.versions.nw)}function isElectron(){if(process.versions&&process.versions.electron)return true;if(process.env.ELECTRON_RUN_AS_NODE)return true;return typeof window!=="undefined"&&window.process&&window.process.type==="renderer"}function isAlpine(e){return e==="linux"&&fs.existsSync("/etc/alpine-release")}load.parseTags=parseTags;load.matchTags=matchTags;load.compareTags=compareTags;load.parseTuple=parseTuple;load.matchTuple=matchTuple;load.compareTuples=compareTuples},1758:(e,t,r)=>{var s=process.env.DEBUG_NOPT||process.env.NOPT_DEBUG?function(){console.error.apply(console,arguments)}:function(){};var a=r(7310),o=r(1017),u=r(2781).Stream,c=r(351),f=r(2037);e.exports=t=nopt;t.clean=clean;t.typeDefs={String:{type:String,validate:validateString},Boolean:{type:Boolean,validate:validateBoolean},url:{type:a,validate:validateUrl},Number:{type:Number,validate:validateNumber},path:{type:o,validate:validatePath},Stream:{type:u,validate:validateStream},Date:{type:Date,validate:validateDate}};function nopt(e,r,a,o){a=a||process.argv;e=e||{};r=r||{};if(typeof o!=="number")o=2;s(e,r,a,o);a=a.slice(o);var u={},c,f={remain:[],cooked:a,original:a.slice(0)};parse(a,u,f.remain,e,r);clean(u,e,t.typeDefs);u.argv=f;Object.defineProperty(u.argv,"toString",{value:function(){return this.original.map(JSON.stringify).join(" ")},enumerable:false});return u}function clean(e,r,a){a=a||t.typeDefs;var o={},u=[false,true,null,String,Array];Object.keys(e).forEach((function(c){if(c==="argv")return;var f=e[c],d=Array.isArray(f),p=r[c];if(!d)f=[f];if(!p)p=u;if(p===Array)p=u.concat(Array);if(!Array.isArray(p))p=[p];s("val=%j",f);s("types=",p);f=f.map((function(u){if(typeof u==="string"){s("string %j",u);u=u.trim();if(u==="null"&&~p.indexOf(null)||u==="true"&&(~p.indexOf(true)||~p.indexOf(Boolean))||u==="false"&&(~p.indexOf(false)||~p.indexOf(Boolean))){u=JSON.parse(u);s("jsonable %j",u)}else if(~p.indexOf(Number)&&!isNaN(u)){s("convert to number",u);u=+u}else if(~p.indexOf(Date)&&!isNaN(Date.parse(u))){s("convert to date",u);u=new Date(u)}}if(!r.hasOwnProperty(c)){return u}if(u===false&&~p.indexOf(null)&&!(~p.indexOf(false)||~p.indexOf(Boolean))){u=null}var f={};f[c]=u;s("prevalidated val",f,u,r[c]);if(!validate(f,c,u,r[c],a)){if(t.invalidHandler){t.invalidHandler(c,u,r[c],e)}else if(t.invalidHandler!==false){s("invalid: "+c+"="+u,r[c])}return o}s("validated val",f,u,r[c]);return f[c]})).filter((function(e){return e!==o}));if(!f.length&&p.indexOf(Array)===-1){s("VAL HAS NO LENGTH, DELETE IT",f,c,p.indexOf(Array));delete e[c]}else if(d){s(d,e[c],f);e[c]=f}else e[c]=f[0];s("k=%s val=%j",c,f,e[c])}))}function validateString(e,t,r){e[t]=String(r)}function validatePath(e,t,r){if(r===true)return false;if(r===null)return true;r=String(r);var s=process.platform==="win32",a=s?/^~(\/|\\)/:/^~\//,u=f.homedir();if(u&&r.match(a)){e[t]=o.resolve(u,r.substr(2))}else{e[t]=o.resolve(r)}return true}function validateNumber(e,t,r){s("validate Number %j %j %j",t,r,isNaN(r));if(isNaN(r))return false;e[t]=+r}function validateDate(e,t,r){var a=Date.parse(r);s("validate Date %j %j %j",t,r,a);if(isNaN(a))return false;e[t]=new Date(r)}function validateBoolean(e,t,r){if(r instanceof Boolean)r=r.valueOf();else if(typeof r==="string"){if(!isNaN(r))r=!!+r;else if(r==="null"||r==="false")r=false;else r=true}else r=!!r;e[t]=r}function validateUrl(e,t,r){r=a.parse(String(r));if(!r.host)return false;e[t]=r.href}function validateStream(e,t,r){if(!(r instanceof u))return false;e[t]=r}function validate(e,t,r,a,o){if(Array.isArray(a)){for(var u=0,c=a.length;u<c;u++){if(a[u]===Array)continue;if(validate(e,t,r,a[u],o))return true}delete e[t];return false}if(a===Array)return true;if(a!==a){s("Poison NaN",t,r,a);delete e[t];return false}if(r===a){s("Explicitly allowed %j",r);e[t]=r;return true}var f=false,d=Object.keys(o);for(var u=0,c=d.length;u<c;u++){s("test type %j %j %j",t,r,d[u]);var p=o[d[u]];if(p&&(a&&a.name&&p.type&&p.type.name?a.name===p.type.name:a===p.type)){var h={};f=false!==p.validate(h,t,r);r=h[t];if(f){e[t]=r;break}}}s("OK? %j (%j %j %j)",f,t,r,d[u]);if(!f)delete e[t];return f}function parse(e,t,r,a,o){s("parse",e,t,r);var u=null,f=c(Object.keys(a)),d=c(Object.keys(o));for(var p=0;p<e.length;p++){var h=e[p];s("arg",h);if(h.match(/^-{2,}$/)){r.push.apply(r,e.slice(p+1));e[p]="--";break}var v=false;if(h.charAt(0)==="-"&&h.length>1){var g=h.indexOf("=");if(g>-1){v=true;var D=h.substr(g+1);h=h.substr(0,g);e.splice(p,1,h,D)}var y=resolveShort(h,o,d,f);s("arg=%j shRes=%j",h,y);if(y){s(h,y);e.splice.apply(e,[p,1].concat(y));if(h!==y[0]){p--;continue}}h=h.replace(/^-+/,"");var m=null;while(h.toLowerCase().indexOf("no-")===0){m=!m;h=h.substr(3)}if(f[h])h=f[h];var _=a[h];var E=Array.isArray(_);if(E&&_.length===1){E=false;_=_[0]}var w=_===Array||E&&_.indexOf(Array)!==-1;if(!a.hasOwnProperty(h)&&t.hasOwnProperty(h)){if(!Array.isArray(t[h]))t[h]=[t[h]];w=true}var x,C=e[p+1];var F=typeof m==="boolean"||_===Boolean||E&&_.indexOf(Boolean)!==-1||typeof _==="undefined"&&!v||C==="false"&&(_===null||E&&~_.indexOf(null));if(F){x=!m;if(C==="true"||C==="false"){x=JSON.parse(C);C=null;if(m)x=!x;p++}if(E&&C){if(~_.indexOf(C)){x=C;p++}else if(C==="null"&&~_.indexOf(null)){x=null;p++}else if(!C.match(/^-{2,}[^-]/)&&!isNaN(C)&&~_.indexOf(Number)){x=+C;p++}else if(!C.match(/^-[^-]/)&&~_.indexOf(String)){x=C;p++}}if(w)(t[h]=t[h]||[]).push(x);else t[h]=x;continue}if(_===String){if(C===undefined){C=""}else if(C.match(/^-{1,2}[^-]+/)){C="";p--}}if(C&&C.match(/^-{2,}$/)){C=undefined;p--}x=C===undefined?true:C;if(w)(t[h]=t[h]||[]).push(x);else t[h]=x;p++;continue}r.push(h)}}function resolveShort(e,t,r,a){e=e.replace(/^-+/,"");if(a[e]===e)return null;if(t[e]){if(t[e]&&!Array.isArray(t[e]))t[e]=t[e].split(/\s+/);return t[e]}var o=t.___singles;if(!o){o=Object.keys(t).filter((function(e){return e.length===1})).reduce((function(e,t){e[t]=true;return e}),{});t.___singles=o;s("shorthand singles",o)}var u=e.split("").filter((function(e){return o[e]}));if(u.join("")===e)return u.map((function(e){return t[e]})).reduce((function(e,t){return e.concat(t)}),[]);if(a[e]&&!t[e])return null;if(r[e])e=r[e];if(t[e]&&!Array.isArray(t[e]))t[e]=t[e].split(/\s+/);return t[e]}},9544:(e,t,r)=>{"use strict";var s=r(4906);var a=r(287);var o=r(2361).EventEmitter;var u=t=e.exports=new o;var c=r(3837);var f=r(2656);var d=r(3844);f(true);var p=process.stderr;Object.defineProperty(u,"stream",{set:function(e){p=e;if(this.gauge)this.gauge.setWriteTo(p,p)},get:function(){return p}});var h;u.useColor=function(){return h!=null?h:p.isTTY};u.enableColor=function(){h=true;this.gauge.setTheme({hasColor:h,hasUnicode:v})};u.disableColor=function(){h=false;this.gauge.setTheme({hasColor:h,hasUnicode:v})};u.level="info";u.gauge=new a(p,{enabled:false,theme:{hasColor:u.useColor()},template:[{type:"progressbar",length:20},{type:"activityIndicator",kerning:1,length:1},{type:"section",default:""},":",{type:"logline",kerning:1,default:""}]});u.tracker=new s.TrackerGroup;u.progressEnabled=u.gauge.isEnabled();var v;u.enableUnicode=function(){v=true;this.gauge.setTheme({hasColor:this.useColor(),hasUnicode:v})};u.disableUnicode=function(){v=false;this.gauge.setTheme({hasColor:this.useColor(),hasUnicode:v})};u.setGaugeThemeset=function(e){this.gauge.setThemeset(e)};u.setGaugeTemplate=function(e){this.gauge.setTemplate(e)};u.enableProgress=function(){if(this.progressEnabled)return;this.progressEnabled=true;this.tracker.on("change",this.showProgress);if(this._pause)return;this.gauge.enable()};u.disableProgress=function(){if(!this.progressEnabled)return;this.progressEnabled=false;this.tracker.removeListener("change",this.showProgress);this.gauge.disable()};var g=["newGroup","newItem","newStream"];var mixinLog=function(e){Object.keys(u).forEach((function(t){if(t[0]==="_")return;if(g.filter((function(e){return e===t})).length)return;if(e[t])return;if(typeof u[t]!=="function")return;var r=u[t];e[t]=function(){return r.apply(u,arguments)}}));if(e instanceof s.TrackerGroup){g.forEach((function(t){var r=e[t];e[t]=function(){return mixinLog(r.apply(e,arguments))}}))}return e};g.forEach((function(e){u[e]=function(){return mixinLog(this.tracker[e].apply(this.tracker,arguments))}}));u.clearProgress=function(e){if(!this.progressEnabled)return e&&process.nextTick(e);this.gauge.hide(e)};u.showProgress=function(e,t){if(!this.progressEnabled)return;var r={};if(e)r.section=e;var s=u.record[u.record.length-1];if(s){r.subsection=s.prefix;var a=u.disp[s.level]||s.level;var o=this._format(a,u.style[s.level]);if(s.prefix)o+=" "+this._format(s.prefix,this.prefixStyle);o+=" "+s.message.split(/\r?\n/)[0];r.logline=o}r.completed=t||this.tracker.completed();this.gauge.show(r)}.bind(u);u.pause=function(){this._paused=true;if(this.progressEnabled)this.gauge.disable()};u.resume=function(){if(!this._paused)return;this._paused=false;var e=this._buffer;this._buffer=[];e.forEach((function(e){this.emitLog(e)}),this);if(this.progressEnabled)this.gauge.enable()};u._buffer=[];var D=0;u.record=[];u.maxRecordSize=1e4;u.log=function(e,t,r){var s=this.levels[e];if(s===undefined){return this.emit("error",new Error(c.format("Undefined log level: %j",e)))}var a=new Array(arguments.length-2);var o=null;for(var u=2;u<arguments.length;u++){var f=a[u-2]=arguments[u];if(typeof f==="object"&&f&&f instanceof Error&&f.stack){Object.defineProperty(f,"stack",{value:o=f.stack+"",enumerable:true,writable:true})}}if(o)a.unshift(o+"\n");r=c.format.apply(c,a);var d={id:D++,level:e,prefix:String(t||""),message:r,messageRaw:a};this.emit("log",d);this.emit("log."+e,d);if(d.prefix)this.emit(d.prefix,d);this.record.push(d);var p=this.maxRecordSize;var h=this.record.length-p;if(h>p/10){var v=Math.floor(p*.9);this.record=this.record.slice(-1*v)}this.emitLog(d)}.bind(u);u.emitLog=function(e){if(this._paused){this._buffer.push(e);return}if(this.progressEnabled)this.gauge.pulse(e.prefix);var t=this.levels[e.level];if(t===undefined)return;if(t<this.levels[this.level])return;if(t>0&&!isFinite(t))return;var r=u.disp[e.level]!=null?u.disp[e.level]:e.level;this.clearProgress();e.message.split(/\r?\n/).forEach((function(t){if(this.heading){this.write(this.heading,this.headingStyle);this.write(" ")}this.write(r,u.style[e.level]);var s=e.prefix||"";if(s)this.write(" ");this.write(s,this.prefixStyle);this.write(" "+t+"\n")}),this);this.showProgress()};u._format=function(e,t){if(!p)return;var r="";if(this.useColor()){t=t||{};var s=[];if(t.fg)s.push(t.fg);if(t.bg)s.push("bg"+t.bg[0].toUpperCase()+t.bg.slice(1));if(t.bold)s.push("bold");if(t.underline)s.push("underline");if(t.inverse)s.push("inverse");if(s.length)r+=d.color(s);if(t.beep)r+=d.beep()}r+=e;if(this.useColor()){r+=d.color("reset")}return r};u.write=function(e,t){if(!p)return;p.write(this._format(e,t))};u.addLevel=function(e,t,r,s){if(s==null)s=e;this.levels[e]=t;this.style[e]=r;if(!this[e]){this[e]=function(){var t=new Array(arguments.length+1);t[0]=e;for(var r=0;r<arguments.length;r++){t[r+1]=arguments[r]}return this.log.apply(this,t)}.bind(this)}this.disp[e]=s};u.prefixStyle={fg:"magenta"};u.headingStyle={fg:"white",bg:"black"};u.style={};u.levels={};u.disp={};u.addLevel("silly",-Infinity,{inverse:true},"sill");u.addLevel("verbose",1e3,{fg:"blue",bg:"black"},"verb");u.addLevel("info",2e3,{fg:"green"});u.addLevel("timing",2500,{fg:"green",bg:"black"});u.addLevel("http",3e3,{fg:"green",bg:"black"});u.addLevel("notice",3500,{fg:"blue",bg:"black"});u.addLevel("warn",4e3,{fg:"black",bg:"yellow"},"WARN");u.addLevel("error",5e3,{fg:"red",bg:"black"},"ERR!");u.addLevel("silent",Infinity);u.on("error",(function(){}))},3979:e=>{"use strict";e.exports=Number.isNaN||function(e){return e!==e}},3540:e=>{"use strict";
14/*
15object-assign
16(c) Sindre Sorhus

Calls

no outgoing calls

Tested by

no test coverage detected